mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 13:22:26 +02:00
refactor: console output improvements (#7029)
This commit is contained in:
parent
39486682ba
commit
2b58485c83
9 changed files with 18 additions and 18 deletions
|
@ -69,7 +69,7 @@ export default async function serve(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.success`Serving path=${cliOptions.dir} directory at path=${
|
logger.success`Serving path=${cliOptions.dir} directory at url=${
|
||||||
servingUrl + baseUrl
|
servingUrl + baseUrl
|
||||||
}.`;
|
}.`;
|
||||||
server.listen(port);
|
server.listen(port);
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default async function start(
|
||||||
const urls = prepareUrls(protocol, host, port);
|
const urls = prepareUrls(protocol, host, port);
|
||||||
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
||||||
|
|
||||||
logger.success`Docusaurus website is running at path=${openUrl}.`;
|
logger.success`Docusaurus website is running at url=${openUrl}.`;
|
||||||
|
|
||||||
// Reload files processing.
|
// Reload files processing.
|
||||||
const reload = _.debounce(() => {
|
const reload = _.debounce(() => {
|
||||||
|
@ -68,7 +68,7 @@ export default async function start(
|
||||||
.then(({baseUrl: newBaseUrl}) => {
|
.then(({baseUrl: newBaseUrl}) => {
|
||||||
const newOpenUrl = normalizeUrl([urls.localUrlForBrowser, newBaseUrl]);
|
const newOpenUrl = normalizeUrl([urls.localUrlForBrowser, newBaseUrl]);
|
||||||
if (newOpenUrl !== openUrl) {
|
if (newOpenUrl !== openUrl) {
|
||||||
logger.success`Docusaurus website is running at path=${newOpenUrl}.`;
|
logger.success`Docusaurus website is running at url=${newOpenUrl}.`;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
@ -47,7 +47,7 @@ exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
|
||||||
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
||||||
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInFolderType>
|
type Props = ComponentProps<typeof ComponentInFolderType>;
|
||||||
|
|
||||||
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -64,7 +64,7 @@ exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
|
||||||
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
||||||
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInSubFolderType>
|
type Props = ComponentProps<typeof ComponentInSubFolderType>;
|
||||||
|
|
||||||
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -81,7 +81,7 @@ exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
|
||||||
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
||||||
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof FirstLevelComponentType>
|
type Props = ComponentProps<typeof FirstLevelComponentType>;
|
||||||
|
|
||||||
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -275,7 +275,7 @@ exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
|
||||||
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
||||||
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInFolderType>
|
type Props = ComponentProps<typeof ComponentInFolderType>;
|
||||||
|
|
||||||
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -319,7 +319,7 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFold
|
||||||
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
||||||
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInSubFolderType>
|
type Props = ComponentProps<typeof ComponentInSubFolderType>;
|
||||||
|
|
||||||
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -363,7 +363,7 @@ exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.ts
|
||||||
import type SiblingType from '@theme/ComponentInFolder/Sibling';
|
import type SiblingType from '@theme/ComponentInFolder/Sibling';
|
||||||
import Sibling from '@theme-original/ComponentInFolder/Sibling';
|
import Sibling from '@theme-original/ComponentInFolder/Sibling';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof SiblingType>
|
type Props = ComponentProps<typeof SiblingType>;
|
||||||
|
|
||||||
export default function SiblingWrapper(props: Props): JSX.Element {
|
export default function SiblingWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -405,7 +405,7 @@ exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
|
||||||
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
||||||
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof FirstLevelComponentType>
|
type Props = ComponentProps<typeof FirstLevelComponentType>;
|
||||||
|
|
||||||
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -88,7 +88,7 @@ export async function eject({
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
logger.interpolate`Could not copy file from ${sourceFile} to ${targetFile}`,
|
logger.interpolate`Could not copy file from path=${sourceFile} to path=${targetFile}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return targetFile;
|
return targetFile;
|
||||||
|
@ -126,7 +126,7 @@ export async function wrap({
|
||||||
import type ${componentName}Type from '@theme/${themeComponentName}';
|
import type ${componentName}Type from '@theme/${themeComponentName}';
|
||||||
import ${componentName} from '@theme-${importType}/${themeComponentName}';
|
import ${componentName} from '@theme-${importType}/${themeComponentName}';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ${componentName}Type>
|
type Props = ComponentProps<typeof ${componentName}Type>;
|
||||||
|
|
||||||
export default function ${wrapperComponentName}(props: Props): JSX.Element {
|
export default function ${wrapperComponentName}(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -133,7 +133,7 @@ export default async function swizzle(
|
||||||
typescript,
|
typescript,
|
||||||
});
|
});
|
||||||
logger.success`
|
logger.success`
|
||||||
Created wrapper of name=${componentName} from name=${themeName} in path=${result.createdFiles}.
|
Created wrapper of name=${componentName} from name=${themeName} in path=${result.createdFiles}
|
||||||
`;
|
`;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ Created wrapper of name=${componentName} from name=${themeName} in path=${result
|
||||||
componentName,
|
componentName,
|
||||||
});
|
});
|
||||||
logger.success`
|
logger.success`
|
||||||
Ejected name=${componentName} from name=${themeName} to path=${result.createdFiles}.
|
Ejected name=${componentName} from name=${themeName} to path=${result.createdFiles}
|
||||||
`;
|
`;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ exports[`loadConfig website with incomplete siteConfig 1`] = `
|
||||||
exports[`loadConfig website with useless field (wrong field) in siteConfig 1`] = `
|
exports[`loadConfig website with useless field (wrong field) in siteConfig 1`] = `
|
||||||
"These field(s) (\\"useLessField\\",) are not recognized in docusaurus.config.js.
|
"These field(s) (\\"useLessField\\",) are not recognized in docusaurus.config.js.
|
||||||
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
||||||
See https://docusaurus.io/docs/docusaurus.config.js/#customfields"
|
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadConfig website with valid async config 1`] = `
|
exports[`loadConfig website with valid async config 1`] = `
|
||||||
|
|
|
@ -153,11 +153,11 @@ exports[`normalizeConfig throws error for required fields 1`] = `
|
||||||
\\"stylesheets\\" must be an array
|
\\"stylesheets\\" must be an array
|
||||||
These field(s) (\\"invalidField\\",) are not recognized in docusaurus.config.js.
|
These field(s) (\\"invalidField\\",) are not recognized in docusaurus.config.js.
|
||||||
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
||||||
See https://docusaurus.io/docs/docusaurus.config.js/#customfields"
|
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`normalizeConfig throws error for unknown field 1`] = `
|
exports[`normalizeConfig throws error for unknown field 1`] = `
|
||||||
"These field(s) (\\"invalid\\",) are not recognized in docusaurus.config.js.
|
"These field(s) (\\"invalid\\",) are not recognized in docusaurus.config.js.
|
||||||
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
||||||
See https://docusaurus.io/docs/docusaurus.config.js/#customfields"
|
See https://docusaurus.io/docs/api/docusaurus-config/#customfields"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -258,7 +258,7 @@ export function validateConfig(
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
formattedError = unknownFields
|
formattedError = unknownFields
|
||||||
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${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/docusaurus.config.js/#customfields`
|
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${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`
|
||||||
: formattedError;
|
: formattedError;
|
||||||
throw new Error(formattedError);
|
throw new Error(formattedError);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue