@docusaurus/core 0.0.0-5065 → 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.
@@ -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 = path_1.default.resolve(siteDir, customConfigFilePath ?? utils_1.DEFAULT_CONFIG_FILE_NAME);
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 ${utils_1.DEFAULT_CONFIG_FILE_NAME}.\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`
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
  }
@@ -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-5065",
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-5065",
47
- "@docusaurus/logger": "0.0.0-5065",
48
- "@docusaurus/mdx-loader": "0.0.0-5065",
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-5065",
51
- "@docusaurus/utils-common": "0.0.0-5065",
52
- "@docusaurus/utils-validation": "0.0.0-5065",
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-5065",
111
- "@docusaurus/types": "0.0.0-5065",
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": "aea52e586d5b585549e65c6fbcd8c1d7c6a21939"
131
+ "gitHead": "441e77f61991faa76e06efbc4bd0be7332055945"
132
132
  }