Skip to content

Commit

Permalink
chore: rename siteConfig.js to docusaurus.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun committed Feb 23, 2019
1 parent 870f6da commit b4cf4d1
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions v2/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Breaking Changes

- `siteConfig.js` renamed to `docusaurus.config.js`.
4 changes: 2 additions & 2 deletions v2/lib/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = async function deploy(siteDir) {
siteConfig.organizationName;
if (!organizationName) {
throw new Error(
"Missing project organization name. Did you forget to define 'organizationName' in siteConfig.js? You may also export it via the organizationName environment variable.",
"Missing project organization name. Did you forget to define 'organizationName' in docusaurus.config.js? You may also export it via the organizationName environment variable.",
);
}
const projectName =
Expand All @@ -43,7 +43,7 @@ module.exports = async function deploy(siteDir) {
siteConfig.projectName;
if (!projectName) {
throw new Error(
"Missing project name. Did you forget to define 'projectName' in siteConfig.js? You may also export it via the projectName environment variable.",
"Missing project name. Did you forget to define 'projectName' in docusaurus.config.js? You may also export it via the projectName environment variable.",
);
}

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
[
`../${docsRelativeDir}/**/*.md`,
'blog/**/*.md',
'siteConfig.js',
'docusaurus.config.js',
'sidebars.json',
],
{
Expand Down
2 changes: 1 addition & 1 deletion v2/lib/core/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import docsMetadatas from '@generated/docsMetadatas'; // eslint-disable-line
import env from '@generated/env'; // eslint-disable-line
import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line
import pagesMetadatas from '@generated/pagesMetadatas'; // eslint-disable-line
import siteConfig from '@generated/siteConfig'; //eslint-disable-line
import siteConfig from '@generated/docusaurus.config'; //eslint-disable-line

import DocusaurusContext from '@docusaurus/context';

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/core/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = async function createSitemap({
const {url: siteUrl} = siteConfig;

if (!siteUrl) {
throw new Error('Url in siteConfig.js cannot be empty/undefined');
throw new Error('Url in docusaurus.config.js cannot be empty/undefined');
}

const urls = [];
Expand Down
8 changes: 4 additions & 4 deletions v2/lib/load/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fs = require('fs-extra');
const path = require('path');

module.exports = function loadConfig(siteDir, deleteCache = true) {
const configPath = path.resolve(siteDir, 'siteConfig.js');
const configPath = path.resolve(siteDir, 'docusaurus.config.js');
if (deleteCache) {
delete require.cache[configPath];
}
Expand Down Expand Up @@ -44,7 +44,7 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
const missingFields = requiredFields.filter(field => !config[field]);
if (missingFields && missingFields.length > 0) {
throw new Error(
`${missingFields.join(', ')} fields are missing in siteConfig.js`,
`${missingFields.join(', ')} fields are missing in docusaurus.config.js`,
);
}

Expand Down Expand Up @@ -89,14 +89,14 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
*/
const {customFields = []} = config;

/* We don't allow useless/ not meaningful field */
// We don't allow unused fields.
const allowedFields = [...requiredFields, ...optionalFields, ...customFields];
const uselessFields = Object.keys(config).filter(
field => !allowedFields.includes(field),
);
if (uselessFields && uselessFields.length > 0) {
throw new Error(
`${uselessFields.join(', ')} fields are useless in siteConfig.js`,
`The fields ${uselessFields.join(', ')} are not recognized in docusaurus.config.js`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion v2/lib/load/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
);
if (!defaultLanguage) {
throw new Error(
`Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'`,
`Please set a default language in 'docusaurus.config.js' which is enabled in 'languages.js'`,
);
}
translation.defaultLanguage = defaultLanguage;
Expand Down
2 changes: 1 addition & 1 deletion v2/lib/load/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = async function load(siteDir) {
// @tested - siteConfig
const siteConfig = loadConfig(siteDir);
await generate(
'siteConfig.js',
'docusaurus.config.js',
`export default ${JSON.stringify(siteConfig, null, 2)};`,
);

Expand Down
2 changes: 1 addition & 1 deletion v2/test/core/sitemap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('sitemap', () => {
test('empty site', async () => {
const props = await loadSetup('empty');
expect(createSitemap(props)).rejects.toThrowErrorMatchingInlineSnapshot(
`"Url in siteConfig.js cannot be empty/undefined"`,
`"Url in docusaurus.config.js cannot be empty/undefined"`,
);
});
});
6 changes: 3 additions & 3 deletions v2/test/load/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Object {
expect(() => {
loadConfig(siteDir);
}).toThrowErrorMatchingInlineSnapshot(
`"tagline, organizationName, projectName, url, headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`,
`"tagline, organizationName, projectName, url, headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`,
);
});

Expand All @@ -57,7 +57,7 @@ Object {
expect(() => {
loadConfig(siteDir);
}).toThrowErrorMatchingInlineSnapshot(
`"headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`,
`"headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`,
);
});

Expand All @@ -66,7 +66,7 @@ Object {
expect(() => {
loadConfig(siteDir);
}).toThrowErrorMatchingInlineSnapshot(
`"title, tagline, organizationName, projectName, baseUrl, url, headerLinks, headerIcon, favicon fields are missing in siteConfig.js"`,
`"title, tagline, organizationName, projectName, baseUrl, url, headerLinks, headerIcon, favicon fields are missing in docusaurus.config.js"`,
);
});
});
2 changes: 1 addition & 1 deletion v2/test/load/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('loadEnv', () => {
expect(() => {
loadEnv({siteDir, siteConfig});
}).toThrowErrorMatchingInlineSnapshot(
`"Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'"`,
`"Please set a default language in 'docusaurus.config.js' which is enabled in 'languages.js'"`,
);
});
});
File renamed without changes.

0 comments on commit b4cf4d1

Please sign in to comment.