Skip to content

Commit

Permalink
Compatibility with Docusaurus 2.0.0-beta.21 (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleds authored Jun 23, 2022
1 parent 0576b14 commit e5c0ec7
Show file tree
Hide file tree
Showing 16 changed files with 2,673 additions and 1,526 deletions.
14 changes: 0 additions & 14 deletions cypress/integration/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ describe("test", () => {
navTo([], /generating an iam token/i);
});

it("loads Multi-spec page", () => {
cy.visit("/multi-spec");
navTo(
[
/foods/i,
/burger store/i,
/burger example/i,
/^api$/i,
/list all burgers/i,
],
/list all burgers/i
);
});

it("loads a page with authentication", () => {
cy.visit("/cos/list-buckets");
cy.findByRole("button", { name: /authorize/i }).should("exist");
Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.14",
"@docusaurus/core": "2.0.0-beta.21",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"start-server-and-test": "^1.14.0",
"ts-jest": "^27.0.6",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
"typescript": "^4.7.4"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"license": "MIT",
"dependencies": {
"@docusaurus/logger": "2.0.0-beta.14",
"@docusaurus/logger": "2.0.0-beta.21",
"commander": "^5.1.0",
"fs-extra": "^10.0.0",
"lodash": "^4.17.20",
Expand Down
14 changes: 7 additions & 7 deletions packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0-beta.14",
"@docusaurus/types": "^2.0.0-beta.14",
"@docusaurus/module-type-aliases": "^2.0.0-beta.21",
"@docusaurus/types": "^2.0.0-beta.21",
"@types/axios": "^0.14.0",
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
Expand All @@ -32,10 +32,10 @@
"utility-types": "^3.10.0"
},
"dependencies": {
"@docusaurus/mdx-loader": "^2.0.0-beta.14",
"@docusaurus/plugin-content-docs": "^2.0.0-beta.14",
"@docusaurus/utils": "^2.0.0-beta.14",
"@docusaurus/utils-validation": "^2.0.0-beta.14",
"@docusaurus/mdx-loader": "^2.0.0-beta.21",
"@docusaurus/plugin-content-docs": "^2.0.0-beta.21",
"@docusaurus/utils": "^2.0.0-beta.21",
"@docusaurus/utils-validation": "^2.0.0-beta.21",
"axios": "^0.26.1",
"chalk": "^4.1.2",
"clsx": "^1.1.1",
Expand All @@ -47,7 +47,7 @@
"openapi-to-postmanv2": "^1.2.1",
"postman-collection": "^4.1.0",
"remark-admonitions": "^1.2.1",
"webpack": "^5.61.0"
"webpack": "^5.73.0"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
Expand Down
7 changes: 2 additions & 5 deletions packages/docusaurus-plugin-openapi/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import type {
OptionValidationContext,
ValidationResult,
} from "@docusaurus/types";
import type { OptionValidationContext } from "@docusaurus/types";
import {
Joi,
RemarkPluginsSchema,
Expand Down Expand Up @@ -60,7 +57,7 @@ export const OptionsSchema = Joi.object({
export function validateOptions({
validate,
options: userOptions,
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
}: OptionValidationContext<PluginOptions, PluginOptions>): PluginOptions {
let options = userOptions;

if (options.sidebarCollapsible === false) {
Expand Down
10 changes: 4 additions & 6 deletions packages/docusaurus-plugin-openapi/src/sidebars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

import path from "path";

import {
CategoryMetadataFile,
CategoryMetadataFilenameBase,
} from "@docusaurus/plugin-content-docs/lib/sidebars/generator";
import { validateCategoryMetadataFile } from "@docusaurus/plugin-content-docs/lib/sidebars/validation";
import { CategoryMetadataFile } from "@docusaurus/plugin-content-docs/lib/sidebars/types";
import { posixPath } from "@docusaurus/utils";
import chalk from "chalk";
import clsx from "clsx";
Expand Down Expand Up @@ -42,6 +38,8 @@ type ApiItem = Pick<ApiPageMetadata, keys> & {

type Item = InfoItem | ApiItem;

const CategoryMetadataFilenameBase = "_category_";

function isApiItem(item: Item): item is ApiItem {
return item.type === "api";
}
Expand Down Expand Up @@ -212,7 +210,7 @@ async function readCategoryMetadataFile(
const contentString = await fs.readFile(filePath, { encoding: "utf8" });
const unsafeContent = Yaml.load(contentString);
try {
return validateCategoryMetadataFile(unsafeContent);
return unsafeContent as CategoryMetadataFile; // validateCategoryMetadataFile(unsafeContent);
} catch (e) {
console.error(
chalk.red(
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-openapi/src/types.ts
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 type { RemarkAndRehypePluginOptions } from "@docusaurus/mdx-loader";
import type { MDXOptions } from "@docusaurus/mdx-loader";
import type { Request } from "postman-collection";

import {
Expand All @@ -20,7 +20,7 @@ export type {
PropSidebar,
PropSidebarItem,
} from "@docusaurus/plugin-content-docs-types";
export interface PluginOptions extends RemarkAndRehypePluginOptions {
export interface PluginOptions extends MDXOptions {
id: string;
path: string;
routeBasePath: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/types": "^2.0.0-beta.14",
"@docusaurus/types": "^2.0.0-beta.21",
"@types/webpack-dev-server": "^4.5.0"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-preset-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/types": "^2.0.0-beta.14"
"@docusaurus/types": "^2.0.0-beta.21"
},
"dependencies": {
"@docusaurus/preset-classic": "^2.0.0-beta.14",
"@docusaurus/preset-classic": "^2.0.0-beta.21",
"docusaurus-plugin-openapi": "^0.5.0",
"docusaurus-plugin-proxy": "^0.5.0",
"docusaurus-theme-openapi": "^0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-template-openapi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "2.0.0-beta.14",
"@docusaurus/core": "2.0.0-beta.21",
"docusaurus-preset-openapi": "0.4.0",
"@mdx-js/react": "^1.6.21",
"clsx": "^1.1.1",
Expand Down
7 changes: 4 additions & 3 deletions packages/docusaurus-theme-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0-beta.14",
"@docusaurus/types": "^2.0.0-beta.14",
"@docusaurus/module-type-aliases": "^2.0.0-beta.21",
"@docusaurus/types": "^2.0.0-beta.21",
"@types/concurrently": "^6.3.0",
"@types/crypto-js": "^4.1.0",
"@types/fs-extra": "^9.0.13",
Expand All @@ -36,6 +36,7 @@
"concurrently": "^5.2.0"
},
"dependencies": {
"@docusaurus/theme-common": "^2.0.0-beta.21",
"@mdx-js/react": "^1.6.21",
"@monaco-editor/react": "^4.3.1",
"@reduxjs/toolkit": "^1.7.1",
Expand All @@ -53,7 +54,7 @@
"react-magic-dropzone": "^1.0.1",
"react-redux": "^7.2.0",
"redux-devtools-extension": "^2.13.8",
"webpack": "^5.61.0"
"webpack": "^5.73.0"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import React, { useState } from "react";

import { useColorMode } from "@docusaurus/theme-common";
import Editor, { Monaco } from "@monaco-editor/react";
import useThemeContext from "@theme/hooks/useThemeContext";

import styles from "./styles.module.css";

Expand All @@ -21,7 +21,8 @@ interface Props {
function VSCode({ value, language, onChange }: Props) {
const [focused, setFocused] = useState(false);

const { isDarkTheme } = useThemeContext();
const { colorMode } = useColorMode();
const isDarkTheme = colorMode === "dark";

function handleEditorWillMount(monaco: Monaco) {
const styles = getComputedStyle(document.documentElement);
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-openapi/src/theme/ApiItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import React from "react";

import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
import { PageMetadata } from "@docusaurus/theme-common";
import type { Props } from "@theme/ApiItem";
import DocPaginator from "@theme/DocPaginator";
import Seo from "@theme/Seo";
import clsx from "clsx";

import styles from "./styles.module.css";
Expand All @@ -28,7 +28,7 @@ function ApiItem(props: Props): JSX.Element {

return (
<>
<Seo {...{ title, description, keywords, image }} />
<PageMetadata {...{ title, description, keywords, image }} />

<div className="row">
<div className="col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ApiPageContent({
}, [hiddenSidebar]);

return (
<Layout wrapperClassName="api-wrapper" pageClassName="api-page">
<Layout wrapperClassName="api-wrapper">
<div className={styles.apiPage}>
<BackToTopButton />

Expand Down
Loading

0 comments on commit e5c0ec7

Please sign in to comment.