@docusaurus/core 0.0.0-5061 → 0.0.0-5066
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
CHANGED
|
@@ -148,6 +148,10 @@ cli
|
|
|
148
148
|
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
|
149
149
|
.option('--build', 'build website before serving (default: false)')
|
|
150
150
|
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
151
|
+
.option(
|
|
152
|
+
'--no-open',
|
|
153
|
+
'do not open page in the browser (default: false, or true in CI)',
|
|
154
|
+
)
|
|
151
155
|
.action(async (siteDir, options) =>
|
|
152
156
|
serve(await resolveDir(siteDir), options),
|
|
153
157
|
);
|
package/lib/commands/serve.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ import type { LoadContextOptions } from '../server';
|
|
|
9
9
|
export declare type ServeCLIOptions = HostPortOptions & Pick<LoadContextOptions, 'config'> & {
|
|
10
10
|
dir?: string;
|
|
11
11
|
build?: boolean;
|
|
12
|
+
open?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export declare function serve(siteDir: string, cliOptions: Partial<ServeCLIOptions>): Promise<void>;
|
package/lib/commands/serve.js
CHANGED
|
@@ -13,6 +13,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
|
|
|
13
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
16
|
+
const openBrowser_1 = tslib_1.__importDefault(require("react-dev-utils/openBrowser"));
|
|
16
17
|
const config_1 = require("../server/config");
|
|
17
18
|
const build_1 = require("./build");
|
|
18
19
|
const getHostPort_1 = require("../server/getHostPort");
|
|
@@ -53,7 +54,11 @@ async function serve(siteDir, cliOptions) {
|
|
|
53
54
|
directoryListing: false,
|
|
54
55
|
});
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
+
const url = servingUrl + baseUrl;
|
|
58
|
+
logger_1.default.success `Serving path=${buildDir} directory at: url=${url}`;
|
|
57
59
|
server.listen(port);
|
|
60
|
+
if (cliOptions.open && !process.env.CI) {
|
|
61
|
+
(0, openBrowser_1.default)(url);
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
64
|
exports.serve = serve;
|
package/lib/server/config.js
CHANGED
|
@@ -11,10 +11,25 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
13
|
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
14
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
15
|
const utils_1 = require("@docusaurus/utils");
|
|
15
16
|
const configValidation_1 = require("./configValidation");
|
|
17
|
+
async function findConfig(siteDir) {
|
|
18
|
+
// We could support .mjs, .ts, etc. in the future
|
|
19
|
+
const candidates = ['.js', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
|
|
20
|
+
const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
|
|
21
|
+
if (!configPath) {
|
|
22
|
+
logger_1.default.error('No config file found.');
|
|
23
|
+
logger_1.default.info `Expected one of:${candidates}
|
|
24
|
+
You can provide a custom config path with the code=${'--config'} option.`;
|
|
25
|
+
throw new Error();
|
|
26
|
+
}
|
|
27
|
+
return configPath;
|
|
28
|
+
}
|
|
16
29
|
async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
17
|
-
const siteConfigPath =
|
|
30
|
+
const siteConfigPath = customConfigFilePath
|
|
31
|
+
? path_1.default.resolve(siteDir, customConfigFilePath)
|
|
32
|
+
: await findConfig(siteDir);
|
|
18
33
|
if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
|
|
19
34
|
throw new Error(`Config file at "${siteConfigPath}" not found.`);
|
|
20
35
|
}
|
|
@@ -22,7 +37,7 @@ async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
|
22
37
|
const loadedConfig = typeof importedConfig === 'function'
|
|
23
38
|
? await importedConfig()
|
|
24
39
|
: await importedConfig;
|
|
25
|
-
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig);
|
|
40
|
+
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig, path_1.default.relative(siteDir, siteConfigPath));
|
|
26
41
|
return { siteConfig, siteConfigPath };
|
|
27
42
|
}
|
|
28
43
|
exports.loadSiteConfig = loadSiteConfig;
|
|
@@ -9,4 +9,4 @@ import type { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
|
|
|
9
9
|
export declare const DEFAULT_I18N_CONFIG: I18nConfig;
|
|
10
10
|
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'stylesheets' | 'scripts' | 'clientModules' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
|
|
11
11
|
export declare const ConfigSchema: Joi.ObjectSchema<DocusaurusConfig>;
|
|
12
|
-
export declare function validateConfig(config: unknown): DocusaurusConfig;
|
|
12
|
+
export declare function validateConfig(config: unknown, siteConfigPath: string): DocusaurusConfig;
|
|
@@ -181,7 +181,7 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
|
181
181
|
'docusaurus.configValidationWarning': 'Docusaurus config validation warning. Field {#label}: {#warningMessage}',
|
|
182
182
|
});
|
|
183
183
|
// TODO move to @docusaurus/utils-validation
|
|
184
|
-
function validateConfig(config) {
|
|
184
|
+
function validateConfig(config, siteConfigPath) {
|
|
185
185
|
const { error, warning, value } = exports.ConfigSchema.validate(config, {
|
|
186
186
|
abortEarly: false,
|
|
187
187
|
});
|
|
@@ -197,7 +197,7 @@ function validateConfig(config) {
|
|
|
197
197
|
? `${accumulatedErr}${err.message}\n`
|
|
198
198
|
: accumulatedErr, '');
|
|
199
199
|
formattedError = unknownFields
|
|
200
|
-
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${
|
|
200
|
+
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${siteConfigPath}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/api/docusaurus-config/#customfields`
|
|
201
201
|
: formattedError;
|
|
202
202
|
throw new Error(formattedError);
|
|
203
203
|
}
|
package/lib/server/index.js
CHANGED
|
@@ -90,7 +90,7 @@ DO NOT hand-modify files in this folder because they will be overwritten in the
|
|
|
90
90
|
next build. You can clear all build artifacts (including this folder) with the
|
|
91
91
|
\`docusaurus clear\` command.
|
|
92
92
|
`);
|
|
93
|
-
const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME
|
|
93
|
+
const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, `${utils_1.DEFAULT_CONFIG_FILE_NAME}.mjs`, `/*
|
|
94
94
|
* AUTOGENERATED - DON'T EDIT
|
|
95
95
|
* Your edits in this file will be overwritten in the next build!
|
|
96
96
|
* Modify the docusaurus.config.js file at your site's root instead.
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-5066",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.18.0",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.18.0",
|
|
45
45
|
"@babel/traverse": "^7.18.0",
|
|
46
|
-
"@docusaurus/cssnano-preset": "0.0.0-
|
|
47
|
-
"@docusaurus/logger": "0.0.0-
|
|
48
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
46
|
+
"@docusaurus/cssnano-preset": "0.0.0-5066",
|
|
47
|
+
"@docusaurus/logger": "0.0.0-5066",
|
|
48
|
+
"@docusaurus/mdx-loader": "0.0.0-5066",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "0.0.0-
|
|
51
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
52
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
50
|
+
"@docusaurus/utils": "0.0.0-5066",
|
|
51
|
+
"@docusaurus/utils-common": "0.0.0-5066",
|
|
52
|
+
"@docusaurus/utils-validation": "0.0.0-5066",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.4",
|
|
54
54
|
"@svgr/webpack": "^6.2.1",
|
|
55
55
|
"autoprefixer": "^10.4.7",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"webpackbar": "^5.0.2"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
111
|
-
"@docusaurus/types": "0.0.0-
|
|
110
|
+
"@docusaurus/module-type-aliases": "0.0.0-5066",
|
|
111
|
+
"@docusaurus/types": "0.0.0-5066",
|
|
112
112
|
"@types/detect-port": "^1.3.2",
|
|
113
113
|
"@types/react-dom": "^18.0.4",
|
|
114
114
|
"@types/react-router-config": "^5.0.6",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"engines": {
|
|
129
129
|
"node": ">=16.14"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "441e77f61991faa76e06efbc4bd0be7332055945"
|
|
132
132
|
}
|