@docusaurus/core 3.6.1 → 3.6.2-canary-6154
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/docusaurus.mjs +15 -268
- package/lib/commands/cli.d.ts +17 -0
- package/lib/commands/cli.js +154 -0
- package/lib/commands/external.d.ts +5 -1
- package/lib/commands/external.js +3 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/server/config.js +5 -4
- package/lib/webpack/base.js +14 -0
- package/package.json +11 -11
package/bin/docusaurus.mjs
CHANGED
|
@@ -10,19 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
import {inspect} from 'node:util';
|
|
12
12
|
import {logger} from '@docusaurus/logger';
|
|
13
|
-
import cli from 'commander';
|
|
14
13
|
import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
|
|
15
|
-
import {
|
|
16
|
-
build,
|
|
17
|
-
swizzle,
|
|
18
|
-
deploy,
|
|
19
|
-
start,
|
|
20
|
-
externalCommand,
|
|
21
|
-
serve,
|
|
22
|
-
clear,
|
|
23
|
-
writeTranslations,
|
|
24
|
-
writeHeadingIds,
|
|
25
|
-
} from '../lib/index.js';
|
|
14
|
+
import {runCLI} from '../lib/index.js';
|
|
26
15
|
import beforeCli from './beforeCli.mjs';
|
|
27
16
|
|
|
28
17
|
// Env variables are initialized to dev, but can be overridden by each command
|
|
@@ -31,270 +20,28 @@ import beforeCli from './beforeCli.mjs';
|
|
|
31
20
|
process.env.BABEL_ENV ??= 'development';
|
|
32
21
|
process.env.NODE_ENV ??= 'development';
|
|
33
22
|
|
|
34
|
-
await beforeCli();
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {string} locale
|
|
38
|
-
* @param {string[]} locales
|
|
39
|
-
* @returns {string[]}
|
|
40
|
-
*/
|
|
41
|
-
function concatLocaleOptions(locale, locales = []) {
|
|
42
|
-
return locales.concat(locale);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
|
|
46
|
-
|
|
47
|
-
cli
|
|
48
|
-
.command('build [siteDir]')
|
|
49
|
-
.description('Build website.')
|
|
50
|
-
.option(
|
|
51
|
-
'--dev',
|
|
52
|
-
'Builds the website in dev mode, including full React error messages.',
|
|
53
|
-
)
|
|
54
|
-
.option(
|
|
55
|
-
'--bundle-analyzer',
|
|
56
|
-
'visualize size of webpack output files with an interactive zoomable tree map (default: false)',
|
|
57
|
-
)
|
|
58
|
-
.option(
|
|
59
|
-
'--out-dir <dir>',
|
|
60
|
-
'the full path for the new output directory, relative to the current workspace (default: build)',
|
|
61
|
-
)
|
|
62
|
-
.option(
|
|
63
|
-
'--config <config>',
|
|
64
|
-
'path to docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
65
|
-
)
|
|
66
|
-
.option(
|
|
67
|
-
'-l, --locale <locale...>',
|
|
68
|
-
'build the site in the specified locale(s). Build all known locales otherwise',
|
|
69
|
-
concatLocaleOptions,
|
|
70
|
-
)
|
|
71
|
-
.option(
|
|
72
|
-
'--no-minify',
|
|
73
|
-
'build website without minimizing JS bundles (default: false)',
|
|
74
|
-
)
|
|
75
|
-
.action(build);
|
|
76
|
-
|
|
77
|
-
cli
|
|
78
|
-
.command('swizzle [themeName] [componentName] [siteDir]')
|
|
79
|
-
.description(
|
|
80
|
-
'Wraps or ejects the original theme files into website folder for customization.',
|
|
81
|
-
)
|
|
82
|
-
.option(
|
|
83
|
-
'-w, --wrap',
|
|
84
|
-
'Creates a wrapper around the original theme component.\nAllows rendering other components before/after the original theme component.',
|
|
85
|
-
)
|
|
86
|
-
.option(
|
|
87
|
-
'-e, --eject',
|
|
88
|
-
'Ejects the full source code of the original theme component.\nAllows overriding the original component entirely with your own UI and logic.',
|
|
89
|
-
)
|
|
90
|
-
.option(
|
|
91
|
-
'-l, --list',
|
|
92
|
-
'only list the available themes/components without further prompting (default: false)',
|
|
93
|
-
)
|
|
94
|
-
.option(
|
|
95
|
-
'-t, --typescript',
|
|
96
|
-
'copy TypeScript theme files when possible (default: false)',
|
|
97
|
-
)
|
|
98
|
-
.option(
|
|
99
|
-
'-j, --javascript',
|
|
100
|
-
'copy JavaScript theme files when possible (default: false)',
|
|
101
|
-
)
|
|
102
|
-
.option('--danger', 'enable swizzle for unsafe component of themes')
|
|
103
|
-
.option(
|
|
104
|
-
'--config <config>',
|
|
105
|
-
'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
106
|
-
)
|
|
107
|
-
.action(swizzle);
|
|
108
|
-
|
|
109
|
-
cli
|
|
110
|
-
.command('deploy [siteDir]')
|
|
111
|
-
.description('Deploy website to GitHub pages.')
|
|
112
|
-
.option(
|
|
113
|
-
'-l, --locale <locale>',
|
|
114
|
-
'deploy the site in the specified locale(s). Deploy all known locales otherwise',
|
|
115
|
-
concatLocaleOptions,
|
|
116
|
-
)
|
|
117
|
-
.option(
|
|
118
|
-
'--out-dir <dir>',
|
|
119
|
-
'the full path for the new output directory, relative to the current workspace (default: build)',
|
|
120
|
-
)
|
|
121
|
-
.option(
|
|
122
|
-
'--config <config>',
|
|
123
|
-
'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
124
|
-
)
|
|
125
|
-
.option(
|
|
126
|
-
'--skip-build',
|
|
127
|
-
'skip building website before deploy it (default: false)',
|
|
128
|
-
)
|
|
129
|
-
.option(
|
|
130
|
-
'--target-dir <dir>',
|
|
131
|
-
'path to the target directory to deploy to (default: `.`)',
|
|
132
|
-
)
|
|
133
|
-
.action(deploy);
|
|
134
|
-
|
|
135
23
|
/**
|
|
136
|
-
* @param {
|
|
137
|
-
* @returns {boolean | number}
|
|
24
|
+
* @param {unknown} error
|
|
138
25
|
*/
|
|
139
|
-
function
|
|
140
|
-
if (value === undefined || value === '') {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const parsedIntValue = Number.parseInt(value, 10);
|
|
145
|
-
if (!Number.isNaN(parsedIntValue)) {
|
|
146
|
-
return parsedIntValue;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return value === 'true';
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
cli
|
|
153
|
-
.command('start [siteDir]')
|
|
154
|
-
.description('Start the development server.')
|
|
155
|
-
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
156
|
-
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
157
|
-
.option('-l, --locale <locale>', 'use specified site locale')
|
|
158
|
-
.option(
|
|
159
|
-
'--hot-only',
|
|
160
|
-
'do not fallback to page refresh if hot reload fails (default: false)',
|
|
161
|
-
)
|
|
162
|
-
.option(
|
|
163
|
-
'--config <config>',
|
|
164
|
-
'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
165
|
-
)
|
|
166
|
-
.option('--no-open', 'do not open page in the browser (default: false)')
|
|
167
|
-
.option(
|
|
168
|
-
'--poll [interval]',
|
|
169
|
-
'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds',
|
|
170
|
-
normalizePollValue,
|
|
171
|
-
)
|
|
172
|
-
.option(
|
|
173
|
-
'--no-minify',
|
|
174
|
-
'build website without minimizing JS bundles (default: false)',
|
|
175
|
-
)
|
|
176
|
-
.action(start);
|
|
177
|
-
|
|
178
|
-
cli
|
|
179
|
-
.command('serve [siteDir]')
|
|
180
|
-
.description('Serve website locally.')
|
|
181
|
-
.option(
|
|
182
|
-
'--dir <dir>',
|
|
183
|
-
'the full path for the new output directory, relative to the current workspace (default: build)',
|
|
184
|
-
)
|
|
185
|
-
.option(
|
|
186
|
-
'--config <config>',
|
|
187
|
-
'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
|
188
|
-
)
|
|
189
|
-
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
190
|
-
.option('--build', 'build website before serving (default: false)')
|
|
191
|
-
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
192
|
-
.option(
|
|
193
|
-
'--no-open',
|
|
194
|
-
'do not open page in the browser (default: false, or true in CI)',
|
|
195
|
-
)
|
|
196
|
-
.action(serve);
|
|
197
|
-
|
|
198
|
-
cli
|
|
199
|
-
.command('clear [siteDir]')
|
|
200
|
-
.description('Remove build artifacts.')
|
|
201
|
-
.action(clear);
|
|
202
|
-
|
|
203
|
-
cli
|
|
204
|
-
.command('write-translations [siteDir]')
|
|
205
|
-
.description('Extract required translations of your site.')
|
|
206
|
-
.option(
|
|
207
|
-
'-l, --locale <locale>',
|
|
208
|
-
'the locale folder to write the translations.\n"--locale fr" will write translations in the ./i18n/fr folder.',
|
|
209
|
-
)
|
|
210
|
-
.option(
|
|
211
|
-
'--override',
|
|
212
|
-
'By default, we only append missing translation messages to existing translation files. This option allows to override existing translation messages. Make sure to commit or backup your existing translations, as they may be overridden. (default: false)',
|
|
213
|
-
)
|
|
214
|
-
.option(
|
|
215
|
-
'--config <config>',
|
|
216
|
-
'path to Docusaurus config file (default:`[siteDir]/docusaurus.config.js`)',
|
|
217
|
-
)
|
|
218
|
-
.option(
|
|
219
|
-
'--messagePrefix <messagePrefix>',
|
|
220
|
-
'Allows to init new written messages with a given prefix. This might help you to highlight untranslated message by making them stand out in the UI (default: "")',
|
|
221
|
-
)
|
|
222
|
-
.action(writeTranslations);
|
|
223
|
-
|
|
224
|
-
cli
|
|
225
|
-
.command('write-heading-ids [siteDir] [files...]')
|
|
226
|
-
.description('Generate heading ids in Markdown content.')
|
|
227
|
-
.option(
|
|
228
|
-
'--maintain-case',
|
|
229
|
-
"keep the headings' casing, otherwise make all lowercase (default: false)",
|
|
230
|
-
)
|
|
231
|
-
.option('--overwrite', 'overwrite existing heading IDs (default: false)')
|
|
232
|
-
.action(writeHeadingIds);
|
|
233
|
-
|
|
234
|
-
cli.arguments('<command>').action((cmd) => {
|
|
235
|
-
cli.outputHelp();
|
|
236
|
-
logger.error`Unknown Docusaurus CLI command name=${cmd}.`;
|
|
237
|
-
process.exit(1);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// === The above is the commander configuration ===
|
|
241
|
-
// They don't start any code execution yet until cli.parse() is called below
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @param {string | undefined} command
|
|
245
|
-
*/
|
|
246
|
-
function isInternalCommand(command) {
|
|
247
|
-
return (
|
|
248
|
-
command &&
|
|
249
|
-
[
|
|
250
|
-
'start',
|
|
251
|
-
'build',
|
|
252
|
-
'swizzle',
|
|
253
|
-
'deploy',
|
|
254
|
-
'serve',
|
|
255
|
-
'clear',
|
|
256
|
-
'write-translations',
|
|
257
|
-
'write-heading-ids',
|
|
258
|
-
].includes(command)
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @param {string | undefined} command
|
|
264
|
-
*/
|
|
265
|
-
function isExternalCommand(command) {
|
|
266
|
-
return !!(command && !isInternalCommand(command) && !command.startsWith('-'));
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// No command? We print the help message because Commander doesn't
|
|
270
|
-
// Note argv looks like this: ['../node','../docusaurus.mjs','<command>',...rest]
|
|
271
|
-
if (process.argv.length < 3) {
|
|
272
|
-
cli.outputHelp();
|
|
273
|
-
logger.error`Please provide a Docusaurus CLI command.`;
|
|
274
|
-
process.exit(1);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// There is an unrecognized subcommand
|
|
278
|
-
// Let plugins extend the CLI before parsing
|
|
279
|
-
if (isExternalCommand(process.argv[2])) {
|
|
280
|
-
// TODO: in this step, we must assume default site structure because there's
|
|
281
|
-
// no way to know the siteDir/config yet. Maybe the root cli should be
|
|
282
|
-
// responsible for parsing these arguments?
|
|
283
|
-
// https://github.com/facebook/docusaurus/issues/8903
|
|
284
|
-
await externalCommand(cli);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
cli.parse(process.argv);
|
|
288
|
-
|
|
289
|
-
process.on('unhandledRejection', (err) => {
|
|
26
|
+
function handleError(error) {
|
|
290
27
|
console.log('');
|
|
291
28
|
|
|
292
29
|
// We need to use inspect with increased depth to log the full causal chain
|
|
293
30
|
// By default Node logging has depth=2
|
|
294
31
|
// see also https://github.com/nodejs/node/issues/51637
|
|
295
|
-
logger.error(inspect(
|
|
32
|
+
logger.error(inspect(error, {depth: Infinity}));
|
|
296
33
|
|
|
297
34
|
logger.info`Docusaurus version: number=${DOCUSAURUS_VERSION}
|
|
298
35
|
Node version: number=${process.version}`;
|
|
299
36
|
process.exit(1);
|
|
300
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
process.on('unhandledRejection', handleError);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await beforeCli();
|
|
43
|
+
// @ts-expect-error: we know it has at least 2 args
|
|
44
|
+
await runCLI(process.argv);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
handleError(e);
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 CommanderStatic } from 'commander';
|
|
8
|
+
type CLIProgram = CommanderStatic;
|
|
9
|
+
type CLIArgs = [string, string, ...string[]];
|
|
10
|
+
export declare function runCLI(cliArgs: CLIArgs): Promise<void>;
|
|
11
|
+
export declare function createCLIProgram({ cli, cliArgs, siteDir, config, }: {
|
|
12
|
+
cli: CLIProgram;
|
|
13
|
+
cliArgs: CLIArgs;
|
|
14
|
+
siteDir: string;
|
|
15
|
+
config: string | undefined;
|
|
16
|
+
}): Promise<CLIProgram>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.runCLI = runCLI;
|
|
10
|
+
exports.createCLIProgram = createCLIProgram;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const logger_1 = require("@docusaurus/logger");
|
|
13
|
+
const commander_1 = tslib_1.__importDefault(require("commander"));
|
|
14
|
+
const utils_1 = require("@docusaurus/utils");
|
|
15
|
+
const build_1 = require("./build/build");
|
|
16
|
+
const clear_1 = require("./clear");
|
|
17
|
+
const deploy_1 = require("./deploy");
|
|
18
|
+
const external_1 = require("./external");
|
|
19
|
+
const serve_1 = require("./serve");
|
|
20
|
+
const start_1 = require("./start/start");
|
|
21
|
+
const swizzle_1 = require("./swizzle");
|
|
22
|
+
const writeHeadingIds_1 = require("./writeHeadingIds");
|
|
23
|
+
const writeTranslations_1 = require("./writeTranslations");
|
|
24
|
+
function concatLocaleOptions(locale, locales = []) {
|
|
25
|
+
return locales.concat(locale);
|
|
26
|
+
}
|
|
27
|
+
function isInternalCommand(command) {
|
|
28
|
+
return (command &&
|
|
29
|
+
[
|
|
30
|
+
'start',
|
|
31
|
+
'build',
|
|
32
|
+
'swizzle',
|
|
33
|
+
'deploy',
|
|
34
|
+
'serve',
|
|
35
|
+
'clear',
|
|
36
|
+
'write-translations',
|
|
37
|
+
'write-heading-ids',
|
|
38
|
+
].includes(command));
|
|
39
|
+
}
|
|
40
|
+
// TODO: Annoying, we must assume default site dir is '.' because there's
|
|
41
|
+
// no way to know the siteDir/config yet.
|
|
42
|
+
// The individual CLI commands can declare/read siteDir on their own
|
|
43
|
+
// The env variable is an escape hatch
|
|
44
|
+
// See https://github.com/facebook/docusaurus/issues/8903
|
|
45
|
+
const DEFAULT_SITE_DIR = process.env.DOCUSAURUS_CLI_SITE_DIR ?? '.';
|
|
46
|
+
// Similarly we give an env escape hatch for config
|
|
47
|
+
// See https://github.com/facebook/docusaurus/issues/8903
|
|
48
|
+
const DEFAULT_CONFIG = process.env.DOCUSAURUS_CLI_CONFIG ?? undefined;
|
|
49
|
+
async function runCLI(cliArgs) {
|
|
50
|
+
const program = await createCLIProgram({
|
|
51
|
+
cli: commander_1.default,
|
|
52
|
+
cliArgs,
|
|
53
|
+
siteDir: DEFAULT_SITE_DIR,
|
|
54
|
+
config: DEFAULT_CONFIG,
|
|
55
|
+
});
|
|
56
|
+
await program.parseAsync(cliArgs);
|
|
57
|
+
}
|
|
58
|
+
async function createCLIProgram({ cli, cliArgs, siteDir, config, }) {
|
|
59
|
+
const command = cliArgs[2];
|
|
60
|
+
cli.version(utils_1.DOCUSAURUS_VERSION).usage('<command> [options]');
|
|
61
|
+
cli
|
|
62
|
+
.command('build [siteDir]')
|
|
63
|
+
.description('Build website.')
|
|
64
|
+
.option('--dev', 'Builds the website in dev mode, including full React error messages.')
|
|
65
|
+
.option('--bundle-analyzer', 'visualize size of webpack output files with an interactive zoomable tree map (default: false)')
|
|
66
|
+
.option('--out-dir <dir>', 'the full path for the new output directory, relative to the current workspace (default: build)')
|
|
67
|
+
.option('--config <config>', 'path to docusaurus config file (default: `[siteDir]/docusaurus.config.js`)')
|
|
68
|
+
.option('-l, --locale <locale...>', 'build the site in the specified locale(s). Build all known locales otherwise', concatLocaleOptions)
|
|
69
|
+
.option('--no-minify', 'build website without minimizing JS bundles (default: false)')
|
|
70
|
+
.action(build_1.build);
|
|
71
|
+
cli
|
|
72
|
+
.command('swizzle [themeName] [componentName] [siteDir]')
|
|
73
|
+
.description('Wraps or ejects the original theme files into website folder for customization.')
|
|
74
|
+
.option('-w, --wrap', 'Creates a wrapper around the original theme component.\nAllows rendering other components before/after the original theme component.')
|
|
75
|
+
.option('-e, --eject', 'Ejects the full source code of the original theme component.\nAllows overriding the original component entirely with your own UI and logic.')
|
|
76
|
+
.option('-l, --list', 'only list the available themes/components without further prompting (default: false)')
|
|
77
|
+
.option('-t, --typescript', 'copy TypeScript theme files when possible (default: false)')
|
|
78
|
+
.option('-j, --javascript', 'copy JavaScript theme files when possible (default: false)')
|
|
79
|
+
.option('--danger', 'enable swizzle for unsafe component of themes')
|
|
80
|
+
.option('--config <config>', 'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)')
|
|
81
|
+
.action(swizzle_1.swizzle);
|
|
82
|
+
cli
|
|
83
|
+
.command('deploy [siteDir]')
|
|
84
|
+
.description('Deploy website to GitHub pages.')
|
|
85
|
+
.option('-l, --locale <locale>', 'deploy the site in the specified locale(s). Deploy all known locales otherwise', concatLocaleOptions)
|
|
86
|
+
.option('--out-dir <dir>', 'the full path for the new output directory, relative to the current workspace (default: build)')
|
|
87
|
+
.option('--config <config>', 'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)')
|
|
88
|
+
.option('--skip-build', 'skip building website before deploy it (default: false)')
|
|
89
|
+
.option('--target-dir <dir>', 'path to the target directory to deploy to (default: `.`)')
|
|
90
|
+
.action(deploy_1.deploy);
|
|
91
|
+
function normalizePollValue(value) {
|
|
92
|
+
if (value === undefined || value === '') {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const parsedIntValue = Number.parseInt(value, 10);
|
|
96
|
+
if (!Number.isNaN(parsedIntValue)) {
|
|
97
|
+
return parsedIntValue;
|
|
98
|
+
}
|
|
99
|
+
return value === 'true';
|
|
100
|
+
}
|
|
101
|
+
cli
|
|
102
|
+
.command('start [siteDir]')
|
|
103
|
+
.description('Start the development server.')
|
|
104
|
+
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
105
|
+
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
106
|
+
.option('-l, --locale <locale>', 'use specified site locale')
|
|
107
|
+
.option('--hot-only', 'do not fallback to page refresh if hot reload fails (default: false)')
|
|
108
|
+
.option('--config <config>', 'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)')
|
|
109
|
+
.option('--no-open', 'do not open page in the browser (default: false)')
|
|
110
|
+
.option('--poll [interval]', 'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds', normalizePollValue)
|
|
111
|
+
.option('--no-minify', 'build website without minimizing JS bundles (default: false)')
|
|
112
|
+
.action(start_1.start);
|
|
113
|
+
cli
|
|
114
|
+
.command('serve [siteDir]')
|
|
115
|
+
.description('Serve website locally.')
|
|
116
|
+
.option('--dir <dir>', 'the full path for the new output directory, relative to the current workspace (default: build)')
|
|
117
|
+
.option('--config <config>', 'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)')
|
|
118
|
+
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
119
|
+
.option('--build', 'build website before serving (default: false)')
|
|
120
|
+
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
121
|
+
.option('--no-open', 'do not open page in the browser (default: false, or true in CI)')
|
|
122
|
+
.action(serve_1.serve);
|
|
123
|
+
cli
|
|
124
|
+
.command('clear [siteDir]')
|
|
125
|
+
.description('Remove build artifacts.')
|
|
126
|
+
.action(clear_1.clear);
|
|
127
|
+
cli
|
|
128
|
+
.command('write-translations [siteDir]')
|
|
129
|
+
.description('Extract required translations of your site.')
|
|
130
|
+
.option('-l, --locale <locale>', 'the locale folder to write the translations.\n"--locale fr" will write translations in the ./i18n/fr folder.')
|
|
131
|
+
.option('--override', 'By default, we only append missing translation messages to existing translation files. This option allows to override existing translation messages. Make sure to commit or backup your existing translations, as they may be overridden. (default: false)')
|
|
132
|
+
.option('--config <config>', 'path to Docusaurus config file (default:`[siteDir]/docusaurus.config.js`)')
|
|
133
|
+
.option('--messagePrefix <messagePrefix>', 'Allows to init new written messages with a given prefix. This might help you to highlight untranslated message by making them stand out in the UI (default: "")')
|
|
134
|
+
.action(writeTranslations_1.writeTranslations);
|
|
135
|
+
cli
|
|
136
|
+
.command('write-heading-ids [siteDir] [files...]')
|
|
137
|
+
.description('Generate heading ids in Markdown content.')
|
|
138
|
+
.option('--maintain-case', "keep the headings' casing, otherwise make all lowercase (default: false)")
|
|
139
|
+
.option('--overwrite', 'overwrite existing heading IDs (default: false)')
|
|
140
|
+
.action(writeHeadingIds_1.writeHeadingIds);
|
|
141
|
+
cli.arguments('<command>').action((cmd) => {
|
|
142
|
+
cli.outputHelp();
|
|
143
|
+
if (!cmd) {
|
|
144
|
+
throw new Error(logger_1.logger.interpolate `Missing Docusaurus CLI command.`);
|
|
145
|
+
}
|
|
146
|
+
throw new Error(logger_1.logger.interpolate `Unknown Docusaurus CLI command code=${cmd}`);
|
|
147
|
+
});
|
|
148
|
+
// There is an unrecognized subcommand
|
|
149
|
+
// Let plugins extend the CLI before parsing
|
|
150
|
+
if (!isInternalCommand(command)) {
|
|
151
|
+
await (0, external_1.externalCommand)({ cli, siteDir, config });
|
|
152
|
+
}
|
|
153
|
+
return cli;
|
|
154
|
+
}
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { CommanderStatic } from 'commander';
|
|
8
|
-
export declare function externalCommand(cli:
|
|
8
|
+
export declare function externalCommand({ cli, siteDir: siteDirInput, config, }: {
|
|
9
|
+
cli: CommanderStatic;
|
|
10
|
+
siteDir: string;
|
|
11
|
+
config: string | undefined;
|
|
12
|
+
}): Promise<void>;
|
package/lib/commands/external.js
CHANGED
|
@@ -11,9 +11,9 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const site_1 = require("../server/site");
|
|
13
13
|
const init_1 = require("../server/plugins/init");
|
|
14
|
-
async function externalCommand(cli) {
|
|
15
|
-
const siteDir = await fs_extra_1.default.realpath(
|
|
16
|
-
const context = await (0, site_1.loadContext)({ siteDir });
|
|
14
|
+
async function externalCommand({ cli, siteDir: siteDirInput, config, }) {
|
|
15
|
+
const siteDir = await fs_extra_1.default.realpath(siteDirInput);
|
|
16
|
+
const context = await (0, site_1.loadContext)({ siteDir, config });
|
|
17
17
|
const plugins = await (0, init_1.initPlugins)(context);
|
|
18
18
|
// Plugin Lifecycle - extendCli.
|
|
19
19
|
plugins.forEach((plugin) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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
|
+
export { runCLI } from './commands/cli';
|
|
7
8
|
export { build } from './commands/build/build';
|
|
8
9
|
export { clear } from './commands/clear';
|
|
9
10
|
export { deploy } from './commands/deploy';
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.writeTranslations = exports.writeHeadingIds = exports.swizzle = exports.start = exports.serve = exports.externalCommand = exports.deploy = exports.clear = exports.build = void 0;
|
|
9
|
+
exports.writeTranslations = exports.writeHeadingIds = exports.swizzle = exports.start = exports.serve = exports.externalCommand = exports.deploy = exports.clear = exports.build = exports.runCLI = void 0;
|
|
10
|
+
var cli_1 = require("./commands/cli");
|
|
11
|
+
Object.defineProperty(exports, "runCLI", { enumerable: true, get: function () { return cli_1.runCLI; } });
|
|
10
12
|
var build_1 = require("./commands/build/build");
|
|
11
13
|
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
12
14
|
var clear_1 = require("./commands/clear");
|
package/lib/server/config.js
CHANGED
|
@@ -18,10 +18,11 @@ async function findConfig(siteDir) {
|
|
|
18
18
|
const candidates = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
|
|
19
19
|
const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
|
|
20
20
|
if (!configPath) {
|
|
21
|
-
|
|
22
|
-
logger_1.default.
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const relativeSiteDir = path_1.default.relative(process.cwd(), siteDir);
|
|
22
|
+
throw new Error(logger_1.default.interpolate `No config file found in site dir code=${relativeSiteDir}.
|
|
23
|
+
Expected one of:${candidates.map(logger_1.default.code)}
|
|
24
|
+
You can provide a custom config path with the code=${'--config'} option.
|
|
25
|
+
`);
|
|
25
26
|
}
|
|
26
27
|
return configPath;
|
|
27
28
|
}
|
package/lib/webpack/base.js
CHANGED
|
@@ -89,10 +89,24 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
|
|
|
89
89
|
},
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
+
function getExperiments() {
|
|
93
|
+
if (props.currentBundler.name === 'rspack') {
|
|
94
|
+
return {
|
|
95
|
+
// This is mostly useful in dev
|
|
96
|
+
// See https://rspack.dev/config/experiments#experimentsincremental
|
|
97
|
+
// Produces warnings in production builds
|
|
98
|
+
// See https://github.com/web-infra-dev/rspack/pull/8311#issuecomment-2476014664
|
|
99
|
+
// @ts-expect-error: Rspack-only
|
|
100
|
+
incremental: !isProd,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
92
105
|
return {
|
|
93
106
|
mode,
|
|
94
107
|
name,
|
|
95
108
|
cache: getCache(),
|
|
109
|
+
experiments: getExperiments(),
|
|
96
110
|
output: {
|
|
97
111
|
pathinfo: false,
|
|
98
112
|
path: outDir,
|
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": "3.6.
|
|
4
|
+
"version": "3.6.2-canary-6154",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "3.6.
|
|
37
|
-
"@docusaurus/bundler": "3.6.
|
|
38
|
-
"@docusaurus/logger": "3.6.
|
|
39
|
-
"@docusaurus/mdx-loader": "3.6.
|
|
40
|
-
"@docusaurus/utils": "3.6.
|
|
41
|
-
"@docusaurus/utils-common": "3.6.
|
|
42
|
-
"@docusaurus/utils-validation": "3.6.
|
|
36
|
+
"@docusaurus/babel": "3.6.2-canary-6154",
|
|
37
|
+
"@docusaurus/bundler": "3.6.2-canary-6154",
|
|
38
|
+
"@docusaurus/logger": "3.6.2-canary-6154",
|
|
39
|
+
"@docusaurus/mdx-loader": "3.6.2-canary-6154",
|
|
40
|
+
"@docusaurus/utils": "3.6.2-canary-6154",
|
|
41
|
+
"@docusaurus/utils-common": "3.6.2-canary-6154",
|
|
42
|
+
"@docusaurus/utils-validation": "3.6.2-canary-6154",
|
|
43
43
|
"boxen": "^6.2.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"webpack-merge": "^6.0.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@docusaurus/module-type-aliases": "3.6.
|
|
82
|
-
"@docusaurus/types": "3.6.
|
|
81
|
+
"@docusaurus/module-type-aliases": "3.6.2-canary-6154",
|
|
82
|
+
"@docusaurus/types": "3.6.2-canary-6154",
|
|
83
83
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
84
84
|
"@types/detect-port": "^1.3.3",
|
|
85
85
|
"@types/react-dom": "^18.2.7",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=18.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "9e14a56c4609b1bd4fb6f48a0e3c3757c6acb3b7"
|
|
104
104
|
}
|