@docusaurus/core 2.0.0-beta.ff31de0ff → 2.0.0-rc.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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/docusaurus.mjs +221 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -7
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/ExecutionEnvironment.js +7 -8
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +44 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- 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/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +8 -15
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +109 -136
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +102 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +40 -20
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +111 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +106 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +119 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +48 -28
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +5 -3
- package/lib/server/configValidation.js +105 -44
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -6
- package/lib/server/index.js +86 -173
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +10 -10
- package/lib/server/plugins/index.js +76 -128
- package/lib/server/plugins/init.d.ts +6 -9
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +6 -2
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +16 -22
- package/lib/server/translations/translations.js +41 -73
- package/lib/server/translations/translationsExtractor.d.ts +10 -5
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +56 -58
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +23 -8
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
- package/lib/webpack/utils.d.ts +16 -31
- package/lib/webpack/utils.js +63 -183
- package/package.json +83 -77
- package/bin/docusaurus.js +0 -326
- package/lib/.tsbuildinfo +0 -5682
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -4127
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -39
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -39
- package/lib/server/themes/index.d.ts +0 -8
- package/lib/server/themes/index.js +0 -35
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
package/bin/docusaurus.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const chalk = require('chalk');
|
|
11
|
-
const fs = require('fs-extra');
|
|
12
|
-
const semver = require('semver');
|
|
13
|
-
const path = require('path');
|
|
14
|
-
const cli = require('commander');
|
|
15
|
-
const updateNotifier = require('update-notifier');
|
|
16
|
-
const boxen = require('boxen');
|
|
17
|
-
const {
|
|
18
|
-
build,
|
|
19
|
-
swizzle,
|
|
20
|
-
deploy,
|
|
21
|
-
start,
|
|
22
|
-
externalCommand,
|
|
23
|
-
serve,
|
|
24
|
-
clear,
|
|
25
|
-
writeTranslations,
|
|
26
|
-
writeHeadingIds,
|
|
27
|
-
} = require('../lib');
|
|
28
|
-
const {
|
|
29
|
-
name,
|
|
30
|
-
version,
|
|
31
|
-
engines: {node: requiredVersion},
|
|
32
|
-
} = require('../package.json');
|
|
33
|
-
|
|
34
|
-
// notify user if @docusaurus packages is outdated
|
|
35
|
-
const notifier = updateNotifier({
|
|
36
|
-
pkg: {
|
|
37
|
-
name,
|
|
38
|
-
version,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// allow the user to be notified for updates on the first run
|
|
43
|
-
if (notifier.lastUpdateCheck === Date.now()) {
|
|
44
|
-
notifier.lastUpdateCheck = 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (notifier.update && semver.gt(this.update.latest, this.update.current)) {
|
|
48
|
-
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
49
|
-
const sitePkg = require(path.resolve(process.cwd(), 'package.json'));
|
|
50
|
-
const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies)
|
|
51
|
-
.filter((p) => p.startsWith('@docusaurus'))
|
|
52
|
-
.map((p) => p.concat('@latest'))
|
|
53
|
-
.join(' ');
|
|
54
|
-
const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
|
|
55
|
-
const upgradeCommand = isYarnUsed
|
|
56
|
-
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
57
|
-
: `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
58
|
-
|
|
59
|
-
const boxenOptions = {
|
|
60
|
-
padding: 1,
|
|
61
|
-
margin: 1,
|
|
62
|
-
align: 'center',
|
|
63
|
-
borderColor: 'yellow',
|
|
64
|
-
borderStyle: 'round',
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const docusaurusUpdateMessage = boxen(
|
|
68
|
-
`Update available ${chalk.dim(`${notifier.update.current}`)}${chalk.reset(
|
|
69
|
-
' → ',
|
|
70
|
-
)}${chalk.green(
|
|
71
|
-
`${notifier.update.latest}`,
|
|
72
|
-
)}\n\nTo upgrade Docusaurus packages with the latest version, run the following command:\n${chalk.cyan(
|
|
73
|
-
`${upgradeCommand}`,
|
|
74
|
-
)}`,
|
|
75
|
-
boxenOptions,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
console.log(docusaurusUpdateMessage);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// notify user if node version needs to be updated
|
|
82
|
-
if (!semver.satisfies(process.version, requiredVersion)) {
|
|
83
|
-
console.log(
|
|
84
|
-
chalk.red(`\nMinimum Node version not met :(`) +
|
|
85
|
-
chalk.yellow(
|
|
86
|
-
`\n\nYou are using Node ${process.version}. We require Node ${requiredVersion} or up!\n`,
|
|
87
|
-
),
|
|
88
|
-
);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function wrapCommand(fn) {
|
|
93
|
-
return (...args) =>
|
|
94
|
-
fn(...args).catch((err) => {
|
|
95
|
-
console.error(chalk.red(err.stack));
|
|
96
|
-
process.exitCode = 1;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
cli.version(require('../package.json').version).usage('<command> [options]');
|
|
101
|
-
|
|
102
|
-
cli
|
|
103
|
-
.command('build [siteDir]')
|
|
104
|
-
.description('Build website')
|
|
105
|
-
.option(
|
|
106
|
-
'--bundle-analyzer',
|
|
107
|
-
'Visualize size of webpack output files with an interactive zoomable treemap (default: false)',
|
|
108
|
-
)
|
|
109
|
-
.option(
|
|
110
|
-
'--out-dir <dir>',
|
|
111
|
-
'The full path for the new output directory, relative to the current workspace (default: build).',
|
|
112
|
-
)
|
|
113
|
-
.option(
|
|
114
|
-
'--config <config>',
|
|
115
|
-
'Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js`',
|
|
116
|
-
)
|
|
117
|
-
.option(
|
|
118
|
-
'-l, --locale <locale>',
|
|
119
|
-
'Build the site in a specified locale. Build all known locales otherwise.',
|
|
120
|
-
)
|
|
121
|
-
.option(
|
|
122
|
-
'--no-minify',
|
|
123
|
-
'Build website without minimizing JS bundles (default: false)',
|
|
124
|
-
)
|
|
125
|
-
.action((siteDir = '.', {bundleAnalyzer, config, outDir, locale, minify}) => {
|
|
126
|
-
wrapCommand(build)(path.resolve(siteDir), {
|
|
127
|
-
bundleAnalyzer,
|
|
128
|
-
outDir,
|
|
129
|
-
config,
|
|
130
|
-
locale,
|
|
131
|
-
minify,
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
cli
|
|
136
|
-
.command('swizzle [themeName] [componentName] [siteDir]')
|
|
137
|
-
.description('Copy the theme files into website folder for customization.')
|
|
138
|
-
.option(
|
|
139
|
-
'--typescript',
|
|
140
|
-
'Copy TypeScript theme files when possible (default: false)',
|
|
141
|
-
)
|
|
142
|
-
.option('--danger', 'Enable swizzle for internal component of themes')
|
|
143
|
-
.action((themeName, componentName, siteDir = '.', {typescript, danger}) => {
|
|
144
|
-
wrapCommand(swizzle)(
|
|
145
|
-
path.resolve(siteDir),
|
|
146
|
-
themeName,
|
|
147
|
-
componentName,
|
|
148
|
-
typescript,
|
|
149
|
-
danger,
|
|
150
|
-
);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
cli
|
|
154
|
-
.command('deploy [siteDir]')
|
|
155
|
-
.description('Deploy website to GitHub pages')
|
|
156
|
-
.option(
|
|
157
|
-
'-l, --locale <locale>',
|
|
158
|
-
'Deploy the site in a specified locale. Deploy all known locales otherwise.',
|
|
159
|
-
)
|
|
160
|
-
.option(
|
|
161
|
-
'--out-dir <dir>',
|
|
162
|
-
'The full path for the new output directory, relative to the current workspace (default: build).',
|
|
163
|
-
)
|
|
164
|
-
.option(
|
|
165
|
-
'--config <config>',
|
|
166
|
-
'Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js`',
|
|
167
|
-
)
|
|
168
|
-
.option(
|
|
169
|
-
'--skip-build',
|
|
170
|
-
'Skip building website before deploy it (default: false)',
|
|
171
|
-
)
|
|
172
|
-
.action((siteDir = '.', {outDir, skipBuild, config}) => {
|
|
173
|
-
wrapCommand(deploy)(path.resolve(siteDir), {
|
|
174
|
-
outDir,
|
|
175
|
-
config,
|
|
176
|
-
skipBuild,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
cli
|
|
181
|
-
.command('start [siteDir]')
|
|
182
|
-
.description('Start the development server')
|
|
183
|
-
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
184
|
-
.option('-h, --host <host>', 'use specified host (default: localhost')
|
|
185
|
-
.option('-l, --locale <locale>', 'use specified site locale')
|
|
186
|
-
.option(
|
|
187
|
-
'--hot-only',
|
|
188
|
-
'Do not fallback to page refresh if hot reload fails (default: false)',
|
|
189
|
-
)
|
|
190
|
-
.option(
|
|
191
|
-
'--config <config>',
|
|
192
|
-
'Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js`',
|
|
193
|
-
)
|
|
194
|
-
.option('--no-open', 'Do not open page in the browser (default: false)')
|
|
195
|
-
.option(
|
|
196
|
-
'--poll [interval]',
|
|
197
|
-
'Use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds.',
|
|
198
|
-
)
|
|
199
|
-
.action(
|
|
200
|
-
(siteDir = '.', {port, host, locale, config, hotOnly, open, poll}) => {
|
|
201
|
-
wrapCommand(start)(path.resolve(siteDir), {
|
|
202
|
-
port,
|
|
203
|
-
host,
|
|
204
|
-
locale,
|
|
205
|
-
config,
|
|
206
|
-
hotOnly,
|
|
207
|
-
open,
|
|
208
|
-
poll,
|
|
209
|
-
});
|
|
210
|
-
},
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
cli
|
|
214
|
-
.command('serve [siteDir]')
|
|
215
|
-
.description('Serve website')
|
|
216
|
-
.option(
|
|
217
|
-
'--dir <dir>',
|
|
218
|
-
'The full path for the new output directory, relative to the current workspace (default: build).',
|
|
219
|
-
)
|
|
220
|
-
.option(
|
|
221
|
-
'--config <config>',
|
|
222
|
-
'Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js`',
|
|
223
|
-
)
|
|
224
|
-
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
225
|
-
.option('--build', 'Build website before serving (default: false)')
|
|
226
|
-
.option('-h, --host <host>', 'use specified host (default: localhost')
|
|
227
|
-
.action(
|
|
228
|
-
(
|
|
229
|
-
siteDir = '.',
|
|
230
|
-
{
|
|
231
|
-
dir = 'build',
|
|
232
|
-
port = 3000,
|
|
233
|
-
host = 'localhost',
|
|
234
|
-
build: buildSite = false,
|
|
235
|
-
config,
|
|
236
|
-
},
|
|
237
|
-
) => {
|
|
238
|
-
wrapCommand(serve)(path.resolve(siteDir), {
|
|
239
|
-
dir,
|
|
240
|
-
port,
|
|
241
|
-
build: buildSite,
|
|
242
|
-
config,
|
|
243
|
-
host,
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
cli
|
|
249
|
-
.command('clear [siteDir]')
|
|
250
|
-
.description('Remove build artifacts')
|
|
251
|
-
.action((siteDir = '.') => {
|
|
252
|
-
wrapCommand(clear)(path.resolve(siteDir));
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
cli
|
|
256
|
-
.command('write-translations [siteDir]')
|
|
257
|
-
.description('Extract required translations of your site')
|
|
258
|
-
.option(
|
|
259
|
-
'-l, --locale <locale>',
|
|
260
|
-
'The locale folder to write the translations\n"--locale fr" will write translations in ./i18n/fr folder)',
|
|
261
|
-
)
|
|
262
|
-
.option(
|
|
263
|
-
'--override',
|
|
264
|
-
'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.',
|
|
265
|
-
)
|
|
266
|
-
.option(
|
|
267
|
-
'--config <config>',
|
|
268
|
-
'Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js`',
|
|
269
|
-
)
|
|
270
|
-
.option(
|
|
271
|
-
'--messagePrefix <messagePrefix>',
|
|
272
|
-
'Allows to init new written messages with a given prefix. This might help you to highlight untranslated message to make them stand out in the UI.',
|
|
273
|
-
)
|
|
274
|
-
.action(
|
|
275
|
-
(
|
|
276
|
-
siteDir = '.',
|
|
277
|
-
{locale = undefined, override = false, messagePrefix = '', config},
|
|
278
|
-
) => {
|
|
279
|
-
wrapCommand(writeTranslations)(path.resolve(siteDir), {
|
|
280
|
-
locale,
|
|
281
|
-
override,
|
|
282
|
-
config,
|
|
283
|
-
messagePrefix,
|
|
284
|
-
});
|
|
285
|
-
},
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
cli
|
|
289
|
-
.command('write-heading-ids [contentDir]')
|
|
290
|
-
.description('Generate heading ids in Markdown content')
|
|
291
|
-
.action((siteDir = '.') => {
|
|
292
|
-
wrapCommand(writeHeadingIds)(siteDir);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
cli.arguments('<command>').action((cmd) => {
|
|
296
|
-
cli.outputHelp();
|
|
297
|
-
console.log(` ${chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)}`);
|
|
298
|
-
console.log();
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
function isInternalCommand(command) {
|
|
302
|
-
return [
|
|
303
|
-
'start',
|
|
304
|
-
'build',
|
|
305
|
-
'swizzle',
|
|
306
|
-
'deploy',
|
|
307
|
-
'serve',
|
|
308
|
-
'clear',
|
|
309
|
-
'write-translations',
|
|
310
|
-
'write-heading-ids',
|
|
311
|
-
].includes(command);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
async function run() {
|
|
315
|
-
if (!isInternalCommand(process.argv.slice(2)[0])) {
|
|
316
|
-
await externalCommand(cli, path.resolve('.'));
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
cli.parse(process.argv);
|
|
320
|
-
|
|
321
|
-
if (!process.argv.slice(2).length) {
|
|
322
|
-
cli.outputHelp();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
run();
|