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

Upgrade to beta.20 #176

Merged
merged 9 commits into from
May 14, 2022
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
7 changes: 7 additions & 0 deletions .changeset/gorgeous-flies-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'docusaurus-plugin-redoc': patch
'docusaurus-theme-redoc': patch
'redocusaurus': patch
---

Upgrade to docusaurus-beta.20 and fix Invalid URL errors
5 changes: 5 additions & 0 deletions .changeset/quiet-taxis-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'docusaurus-theme-redoc': patch
---

Fix usage of color mode
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "yarn build:packages && yarn build:website",
"build:packages": "yarn workspaces foreach --exclude redocusaurus-website --exclude redocusaurus-monorepo -tpv run build",
"build:website": "yarn workspace redocusaurus exec 'echo \\\"$npm_package_version\\\" > $PROJECT_CWD/website/version.json' && yarn workspace redocusaurus-website run build",
"clean": "yarn workspaces foreach -Atv exec \"rm -rf dist* .tsbuild*.info\"",
"clean": "yarn workspaces foreach --exclude redocusaurus-monorepo -Atv exec \"rm -rf build .docusaurus dist dist-jsx .tsbuild.info .tsbuild.jsx.info\"",
"dev": "yarn build:packages && yarn workspaces foreach --exclude redocusaurus-monorepo -piv run dev",
"dev:packages": "yarn workspaces foreach --exclude redocusaurus-website --exclude redocusaurus-monorepo -piv run dev",
"dev:website": "yarn workspace redocusaurus-website run dev",
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-plugin-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
},
"homepage": "https://github.com/rohit-gohri/redocusaurus/tree/main/packages/docusaurus-plugin-redoc#readme",
"dependencies": {
"@docusaurus/types": "^2.0.0-beta.17",
"@docusaurus/utils": "^2.0.0-beta.17",
"@redocly/openapi-core": "^1.0.0-beta.87",
"@docusaurus/types": "^2.0.0-beta.20",
"@docusaurus/utils": "^2.0.0-beta.20",
"@redocly/openapi-core": "1.0.0-beta.97",
"joi": "^17.5.0",
"redoc": "^2.0.0-rc.64"
"redoc": "2.0.0-rc.69"
},
"engines": {
"node": ">=14"
Expand Down
16 changes: 9 additions & 7 deletions packages/docusaurus-plugin-redoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default function redocPlugin(
if (typeof config === 'string') {
redoclyConfig = await loadConfig(config);
} else {
redoclyConfig = new Config(config);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
redoclyConfig = new Config(config as any);
}
} else {
redoclyConfig = await loadConfig();
Expand Down Expand Up @@ -185,10 +186,11 @@ export default function redocPlugin(

export function validateOptions({
options,
}: OptionValidationContext<PluginOptions>): PluginOptions {
const { value, error } = PluginOptionSchema.validate(options);
if (error) {
throw error;
}
return value!;
validate,
}: OptionValidationContext<
typeof PluginOptionSchema,
PluginOptions
>): PluginOptions {
const validatedOptions = validate(PluginOptionSchema, options);
return validatedOptions;
}
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-redoc/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Joi from 'joi';
import { RawConfig } from '@redocly/openapi-core';
import type { RawConfig } from '@redocly/openapi-core';

type LayoutProps = {
title?: string;
Expand All @@ -26,7 +26,7 @@ export interface PluginOptions {
* Redocly config to bundle file
* @see https://redocly.com/docs/cli/configuration/configuration-file/
*/
config?: string | Partial<RawConfig>;
config?: string | RawConfig;
}

export interface PluginOptionsWithDefault extends PluginOptions {
Expand Down
11 changes: 5 additions & 6 deletions packages/docusaurus-theme-redoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@
},
"homepage": "https://github.com/rohit-gohri/redocusaurus/tree/main/packages/docusaurus-theme-redoc#readme",
"dependencies": {
"@docusaurus/theme-common": "^2.0.0-beta.17",
"@docusaurus/types": "^2.0.0-beta.17",
"@docusaurus/theme-common": "^2.0.0-beta.20",
"@docusaurus/types": "^2.0.0-beta.20",
"clsx": "^1.1.1",
"copyfiles": "^2.4.1",
"lodash": "^4.17.21",
"mobx": "^6.3.13",
"node-polyfill-webpack-plugin": "^1.1.4",
"redoc": "^2.0.0-rc.64",
"redoc": "2.0.0-rc.69",
"styled-components": "^5.3.3",
"to-arraybuffer": "^1.0.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0-beta.17",
"@docusaurus/theme-classic": "^2.0.0-beta.17",
"@docusaurus/module-type-aliases": "^2.0.0-beta.20",
"@docusaurus/theme-classic": "^2.0.0-beta.20",
"@types/lodash": "^4.14.179",
"@types/react-dom": "^17.0.13",
"@types/react-router-dom": "^5.3.3",
Expand Down
12 changes: 7 additions & 5 deletions packages/docusaurus-theme-redoc/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path';
import type { LoadContext, Plugin } from '@docusaurus/types';
import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
import { ThemeOptions, GlobalData } from './types/options';
import { getGlobalData } from './redocData';

Expand All @@ -19,7 +18,7 @@ export default function redocTheme(
return {
resolve: {
fallback: {
fs: false,
tty: false,
},
},
plugins: [
Expand All @@ -28,11 +27,14 @@ export default function redocTheme(
process.versions.node || '0.0.0',
),
}),
new NodePolyfillPlugin(),
new webpack.NormalModuleReplacementPlugin(
/^redoc$/,
require.resolve('redoc/bundles/redoc.browser.lib'),
),
...(isServer
? [
new webpack.NormalModuleReplacementPlugin(
/theme\/Redoc\/Styles\.jsx/,
/theme\/Redoc\/Styles/,
path.join(__dirname, 'theme', 'Redoc', 'ServerStyles.js'),
),
]
Expand All @@ -44,7 +46,7 @@ export default function redocTheme(
const { setGlobalData } = actions;
const globalData = getGlobalData(options);

setGlobalData<GlobalData>(globalData);
setGlobalData(globalData);
},
getThemePath() {
return path.join(__dirname, '..', 'dist-jsx', 'theme');
Expand Down
10 changes: 5 additions & 5 deletions packages/docusaurus-theme-redoc/src/theme/useSpecData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { SpecProps } from '../types/common';
* @returns Spec Data of ID or first one if ID is not provided
*/
export function useSpecData(id?: string): SpecProps {
const allData = useAllPluginInstancesData<SpecProps>(
'docusaurus-plugin-redoc',
);
const apiData = id ? allData[id as string] : Object.values(allData)[0];
const allData = useAllPluginInstancesData('docusaurus-plugin-redoc');
const apiData = id
? allData?.[id as string]
: Object.values(allData ?? {})?.[0];

return apiData;
return apiData as SpecProps;
}

export default useSpecData;
6 changes: 3 additions & 3 deletions packages/docusaurus-theme-redoc/src/utils/useSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import { GlobalData } from '../types/options';
* Released under the MIT License
*/
export function useSpec({ spec, url }: SpecProps) {
const fullUrl = useBaseUrl(url);
const fullUrl = useBaseUrl(url, { absolute: true });
const isBrowser = useIsBrowser();
const { isDarkTheme } = useColorMode();
const themeOptions = usePluginData<GlobalData>('docusaurus-theme-redoc');
const isDarkTheme = useColorMode().colorMode === 'dark';
const themeOptions = usePluginData('docusaurus-theme-redoc') as GlobalData;

const stores = useMemo(() => {
const { lightTheme, darkTheme, options: redocOptions } = themeOptions;
Expand Down
2 changes: 1 addition & 1 deletion packages/redocusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://redocusaurus.vercel.app/",
"dependencies": {
"@docusaurus/types": "^2.0.0-beta.17",
"@docusaurus/types": "^2.0.0-beta.20",
"docusaurus-plugin-redoc": "1.0.0",
"docusaurus-theme-redoc": "1.0.2"
},
Expand Down
6 changes: 6 additions & 0 deletions website/docs/getting-started/plugin-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ Route URL at which docs would be available, this will use the theme component `@
### layout (optional, object: layoutProps)

An object to pass as layout props. Useful to set title/description of the page. See all properties available [here](https://github.com/rohit-gohri/redocusaurus/blob/main/packages/docusaurus-plugin-redoc/src/options.ts#L3).

### config (optional, string or object: redoclyConfig)

Redocly config to bundle file. You can provide a custom path to a `redocly.yaml` file, if not provided then it will try to load it from the root of your project if it exists.

See: <https://redocly.com/docs/cli/configuration/configuration-file/>
4 changes: 2 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"test": "percy snapshot snapshots.js"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-beta.17",
"@docusaurus/preset-classic": "^2.0.0-beta.17",
"@docusaurus/core": "^2.0.0-beta.20",
"@docusaurus/preset-classic": "^2.0.0-beta.20",
"clsx": "^1.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
Loading