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

This commit is contained in:
Sébastien Lorber 2021-03-18 19:27:51 +01:00 committed by GitHub
parent 03f4a92035
commit 60d189a91c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 26 additions and 27 deletions

View file

@ -25,7 +25,6 @@
"eta": "^1.11.0", "eta": "^1.11.0",
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"globby": "^11.0.2", "globby": "^11.0.2",
"joi": "^17.4.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"tslib": "^2.1.0" "tslib": "^2.1.0"
}, },

View file

@ -6,8 +6,7 @@
*/ */
import {PluginOptions, RedirectOption, UserPluginOptions} from './types'; import {PluginOptions, RedirectOption, UserPluginOptions} from './types';
import * as Joi from 'joi'; import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
import {PathnameSchema} from '@docusaurus/utils-validation';
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants'; import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
export const DefaultPluginOptions: PluginOptions = { export const DefaultPluginOptions: PluginOptions = {

View file

@ -5,9 +5,8 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import * as Joi from 'joi';
import {RedirectMetadata} from './types'; import {RedirectMetadata} from './types';
import {PathnameSchema} from '@docusaurus/utils-validation'; import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
const RedirectSchema = Joi.object<RedirectMetadata>({ const RedirectSchema = Joi.object<RedirectMetadata>({
from: PathnameSchema.required(), from: PathnameSchema.required(),

View file

@ -27,7 +27,6 @@
"feed": "^4.2.2", "feed": "^4.2.2",
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"globby": "^11.0.2", "globby": "^11.0.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3", "loader-utils": "^1.2.3",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"reading-time": "^1.3.0", "reading-time": "^1.3.0",

View file

@ -13,7 +13,7 @@ import pluginContentBlog from '../index';
import {DocusaurusConfig, LoadContext, I18n} from '@docusaurus/types'; import {DocusaurusConfig, LoadContext, I18n} from '@docusaurus/types';
import {PluginOptionSchema} from '../pluginOptionSchema'; import {PluginOptionSchema} from '../pluginOptionSchema';
import {PluginOptions, EditUrlFunction} from '../types'; import {PluginOptions, EditUrlFunction} from '../types';
import Joi from 'joi'; import {Joi} from '@docusaurus/utils-validation';
function getI18n(locale: string): I18n { function getI18n(locale: string): I18n {
return { return {

View file

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import * as Joi from 'joi';
import { import {
Joi,
RemarkPluginsSchema, RemarkPluginsSchema,
RehypePluginsSchema, RehypePluginsSchema,
AdmonitionsSchema, AdmonitionsSchema,

View file

@ -34,7 +34,6 @@
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"globby": "^11.0.2", "globby": "^11.0.2",
"import-fresh": "^3.2.2", "import-fresh": "^3.2.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3", "loader-utils": "^1.2.3",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"remark-admonitions": "^1.2.1", "remark-admonitions": "^1.2.1",

View file

@ -4,9 +4,9 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import * as Joi from 'joi';
import {PluginOptions} from './types'; import {PluginOptions} from './types';
import { import {
Joi,
RemarkPluginsSchema, RemarkPluginsSchema,
RehypePluginsSchema, RehypePluginsSchema,
AdmonitionsSchema, AdmonitionsSchema,

View file

@ -24,7 +24,6 @@
"@docusaurus/utils": "2.0.0-alpha.72", "@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72", "@docusaurus/utils-validation": "2.0.0-alpha.72",
"globby": "^11.0.2", "globby": "^11.0.2",
"joi": "^17.4.0",
"loader-utils": "^1.2.3", "loader-utils": "^1.2.3",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",

View file

@ -4,9 +4,9 @@
* This source code is licensed under the MIT license found in the * This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import * as Joi from 'joi';
import {PluginOptions} from './types'; import {PluginOptions} from './types';
import { import {
Joi,
RemarkPluginsSchema, RemarkPluginsSchema,
RehypePluginsSchema, RehypePluginsSchema,
AdmonitionsSchema, AdmonitionsSchema,

View file

@ -17,10 +17,10 @@
"@babel/plugin-proposal-optional-chaining": "^7.12.16", "@babel/plugin-proposal-optional-chaining": "^7.12.16",
"@babel/preset-env": "^7.12.16", "@babel/preset-env": "^7.12.16",
"@docusaurus/core": "2.0.0-alpha.72", "@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"clsx": "^1.1.1", "clsx": "^1.1.1",
"core-js": "^2.6.5", "core-js": "^2.6.5",
"joi": "^17.4.0",
"terser-webpack-plugin": "^4.1.0", "terser-webpack-plugin": "^4.1.0",
"webpack": "^4.44.1", "webpack": "^4.44.1",
"webpack-merge": "^4.2.2", "webpack-merge": "^4.2.2",

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * 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 path = require('path');
const DEFAULT_OPTIONS = { const DEFAULT_OPTIONS = {

View file

@ -20,8 +20,8 @@
"@docusaurus/core": "2.0.0-alpha.72", "@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/types": "2.0.0-alpha.72", "@docusaurus/types": "2.0.0-alpha.72",
"@docusaurus/utils": "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", "fs-extra": "^9.1.0",
"joi": "^17.4.0",
"sitemap": "^6.3.6", "sitemap": "^6.3.6",
"tslib": "^2.1.0" "tslib": "^2.1.0"
}, },

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * 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 {EnumChangefreq} from 'sitemap';
import {PluginOptions} from './types'; import {PluginOptions} from './types';

View file

@ -40,7 +40,6 @@
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"globby": "^11.0.2", "globby": "^11.0.2",
"infima": "0.2.0-alpha.21", "infima": "0.2.0-alpha.21",
"joi": "^17.4.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"parse-numeric-range": "^1.2.0", "parse-numeric-range": "^1.2.0",
"postcss": "^7.0.2", "postcss": "^7.0.2",

View file

@ -5,8 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
const Joi = require('joi'); const {Joi, URISchema} = require('@docusaurus/utils-validation');
const {URISchema} = require('@docusaurus/utils-validation');
const DEFAULT_DOCS_CONFIG = { const DEFAULT_DOCS_CONFIG = {
versionPersistence: 'localStorage', versionPersistence: 'localStorage',

View file

@ -14,9 +14,9 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@docusaurus/core": "2.0.0-alpha.72", "@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"@philpl/buble": "^0.19.7", "@philpl/buble": "^0.19.7",
"clsx": "^1.1.1", "clsx": "^1.1.1",
"joi": "^17.4.0",
"parse-numeric-range": "^1.2.0", "parse-numeric-range": "^1.2.0",
"prism-react-renderer": "^1.1.1", "prism-react-renderer": "^1.1.1",
"react-live": "^2.2.3" "react-live": "^2.2.3"

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
const Joi = require('joi'); const {Joi} = require('@docusaurus/utils-validation');
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
playgroundPosition: 'bottom', playgroundPosition: 'bottom',

View file

@ -17,11 +17,11 @@
"@docusaurus/core": "2.0.0-alpha.72", "@docusaurus/core": "2.0.0-alpha.72",
"@docusaurus/theme-common": "2.0.0-alpha.72", "@docusaurus/theme-common": "2.0.0-alpha.72",
"@docusaurus/utils": "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": "^4.8.4",
"algoliasearch-helper": "^3.3.4", "algoliasearch-helper": "^3.3.4",
"clsx": "^1.1.1", "clsx": "^1.1.1",
"eta": "^1.12.1", "eta": "^1.12.1",
"joi": "^17.4.0",
"lodash": "^4.17.20" "lodash": "^4.17.20"
}, },
"peerDependencies": { "peerDependencies": {

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
const Joi = require('joi'); const {Joi} = require('@docusaurus/utils-validation');
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
contextualSearch: false, // future: maybe we want to enable this by default contextualSearch: false, // future: maybe we want to enable this by default

View file

@ -19,6 +19,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@docusaurus/utils": "2.0.0-alpha.72", "@docusaurus/utils": "2.0.0-alpha.72",
"@docusaurus/utils-validation": "2.0.0-alpha.72",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"joi": "^17.4.0", "joi": "^17.4.0",
"tslib": "^2.1.0" "tslib": "^2.1.0"

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
import * as Joi from 'joi'; import {Joi} from '@docusaurus/utils-validation';
import { import {
AdmonitionsSchema, AdmonitionsSchema,

View file

@ -5,5 +5,8 @@
* LICENSE file in the root directory of this source tree. * 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 './validationUtils';
export * from './validationSchemas'; export * from './validationSchemas';

View file

@ -81,7 +81,6 @@
"html-webpack-plugin": "^4.5.0", "html-webpack-plugin": "^4.5.0",
"import-fresh": "^3.3.0", "import-fresh": "^3.3.0",
"is-root": "^2.1.0", "is-root": "^2.1.0",
"joi": "^17.4.0",
"leven": "^3.1.0", "leven": "^3.1.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"mini-css-extract-plugin": "^0.8.0", "mini-css-extract-plugin": "^0.8.0",

View file

@ -7,8 +7,8 @@
import {DocusaurusConfig, I18nConfig} from '@docusaurus/types'; import {DocusaurusConfig, I18nConfig} from '@docusaurus/types';
import {DEFAULT_CONFIG_FILE_NAME} from '../constants'; import {DEFAULT_CONFIG_FILE_NAME} from '../constants';
import Joi from 'joi';
import { import {
Joi,
logValidationBugReportHint, logValidationBugReportHint,
isValidationDisabledEscapeHatch, isValidationDisabledEscapeHatch,
URISchema, URISchema,

View file

@ -14,7 +14,7 @@ import {
TranslationMessage, TranslationMessage,
} from '@docusaurus/types'; } from '@docusaurus/types';
import {getPluginI18nPath, toMessageRelativeFilePath} from '@docusaurus/utils'; import {getPluginI18nPath, toMessageRelativeFilePath} from '@docusaurus/utils';
import * as Joi from 'joi'; import {Joi} from '@docusaurus/utils-validation';
import chalk from 'chalk'; import chalk from 'chalk';
export type WriteTranslationsOptions = { export type WriteTranslationsOptions = {

View file

@ -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. [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. 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.
@ -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. [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. If you don't use **[Joi](https://www.npmjs.com/package/joi)** for validation you can throw an Error in case of invalid options.