Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2): Export Joi from validation-utils package #4459

Merged
merged 1 commit into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-client-redirects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"eta": "^1.11.0",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"joi": "^17.4.0",
"lodash": "^4.17.20",
"tslib": "^2.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
*/

import {PluginOptions, RedirectOption, UserPluginOptions} from './types';
import * as Joi from 'joi';
import {PathnameSchema} from '@docusaurus/utils-validation';
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';

export const DefaultPluginOptions: PluginOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import * as Joi from 'joi';
import {RedirectMetadata} from './types';
import {PathnameSchema} from '@docusaurus/utils-validation';
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';

const RedirectSchema = Joi.object<RedirectMetadata>({
from: PathnameSchema.required(),
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"feed": "^4.2.2",
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.20",
"reading-time": "^1.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import pluginContentBlog from '../index';
import {DocusaurusConfig, LoadContext, I18n} from '@docusaurus/types';
import {PluginOptionSchema} from '../pluginOptionSchema';
import {PluginOptions, EditUrlFunction} from '../types';
import Joi from 'joi';
import {Joi} from '@docusaurus/utils-validation';

function getI18n(locale: string): I18n {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import * as Joi from 'joi';
import {
Joi,
RemarkPluginsSchema,
RehypePluginsSchema,
AdmonitionsSchema,
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"import-fresh": "^3.2.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.20",
"remark-admonitions": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as Joi from 'joi';
import {PluginOptions} from './types';
import {
Joi,
RemarkPluginsSchema,
RehypePluginsSchema,
AdmonitionsSchema,
Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"globby": "^11.0.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.20",
"minimatch": "^3.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as Joi from 'joi';
import {PluginOptions} from './types';
import {
Joi,
RemarkPluginsSchema,
RehypePluginsSchema,
AdmonitionsSchema,
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
"@babel/preset-env": "^7.12.16",
"@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"babel-loader": "^8.2.2",
"clsx": "^1.1.1",
"core-js": "^2.6.5",
"joi": "^17.4.0",
"terser-webpack-plugin": "^4.1.0",
"webpack": "^4.44.1",
"webpack-merge": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-pwa/src/pluginOptionSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const Joi = require('joi');
const {Joi} = require('@docusaurus/utils-validation');
const path = require('path');

const DEFAULT_OPTIONS = {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/types": "2.0.0-alpha.72",
"@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"fs-extra": "^9.1.0",
"joi": "^17.4.0",
"sitemap": "^6.3.6",
"tslib": "^2.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import * as Joi from 'joi';
import {Joi} from '@docusaurus/utils-validation';
import {EnumChangefreq} from 'sitemap';
import {PluginOptions} from './types';

Expand Down
1 change: 0 additions & 1 deletion packages/docusaurus-theme-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"fs-extra": "^9.1.0",
"globby": "^11.0.2",
"infima": "0.2.0-alpha.21",
"joi": "^17.4.0",
"lodash": "^4.17.20",
"parse-numeric-range": "^1.2.0",
"postcss": "^7.0.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/docusaurus-theme-classic/src/validateThemeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const Joi = require('joi');
const {URISchema} = require('@docusaurus/utils-validation');
const {Joi, URISchema} = require('@docusaurus/utils-validation');

const DEFAULT_DOCS_CONFIG = {
versionPersistence: 'localStorage',
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-live-codeblock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"license": "MIT",
"dependencies": {
"@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"@philpl/buble": "^0.19.7",
"clsx": "^1.1.1",
"joi": "^17.4.0",
"parse-numeric-range": "^1.2.0",
"prism-react-renderer": "^1.1.1",
"react-live": "^2.2.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const Joi = require('joi');
const {Joi} = require('@docusaurus/utils-validation');

const DEFAULT_CONFIG = {
playgroundPosition: 'bottom',
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/theme-common": "2.0.0-alpha.72",
"@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"algoliasearch": "^4.8.4",
"algoliasearch-helper": "^3.3.4",
"clsx": "^1.1.1",
"eta": "^1.12.1",
"joi": "^17.4.0",
"lodash": "^4.17.20"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const Joi = require('joi');
const {Joi} = require('@docusaurus/utils-validation');

const DEFAULT_CONFIG = {
contextualSearch: false, // future: maybe we want to enable this by default
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-utils-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"license": "MIT",
"dependencies": {
"@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"chalk": "^4.1.0",
"joi": "^17.4.0",
"tslib": "^2.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import * as Joi from 'joi';
import {Joi} from '@docusaurus/utils-validation';

import {
AdmonitionsSchema,
Expand Down
3 changes: 3 additions & 0 deletions packages/docusaurus-utils-validation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

// /!\ don't remove this export, as we recommend plugin authors to use it
export {default as Joi} from 'joi';

export * from './validationUtils';
export * from './validationSchemas';
1 change: 0 additions & 1 deletion packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"html-webpack-plugin": "^4.5.0",
"import-fresh": "^3.3.0",
"is-root": "^2.1.0",
"joi": "^17.4.0",
"leven": "^3.1.0",
"lodash": "^4.17.20",
"mini-css-extract-plugin": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/server/configValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import {DocusaurusConfig, I18nConfig} from '@docusaurus/types';
import {DEFAULT_CONFIG_FILE_NAME} from '../constants';
import Joi from 'joi';
import {
Joi,
logValidationBugReportHint,
isValidationDisabledEscapeHatch,
URISchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
TranslationMessage,
} from '@docusaurus/types';
import {getPluginI18nPath, toMessageRelativeFilePath} from '@docusaurus/utils';
import * as Joi from 'joi';
import {Joi} from '@docusaurus/utils-validation';
import chalk from 'chalk';

export type WriteTranslationsOptions = {
Expand Down
4 changes: 4 additions & 0 deletions website/docs/lifecycle-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Return validated and normalized options for the plugin. This method is called be

[Joi](https://www.npmjs.com/package/joi) is recommended for validation and normalization of options.

To avoid mixing Joi versions, use `const {Joi} = require("@docusaurus/utils-validation")`

:::

If you don't use **[Joi](https://www.npmjs.com/package/joi)** for validation you can throw an Error in case of invalid options and return options in case of success.
Expand Down Expand Up @@ -77,6 +79,8 @@ Return validated and normalized configuration for the theme.

[Joi](https://www.npmjs.com/package/joi) is recommended for validation and normalization of theme config.

To avoid mixing Joi versions, use `const {Joi} = require("@docusaurus/utils-validation")`

:::

If you don't use **[Joi](https://www.npmjs.com/package/joi)** for validation you can throw an Error in case of invalid options.
Expand Down