Skip to content

Commit

Permalink
Start monorepo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLorantfy committed Jun 9, 2024
1 parent 4b028bb commit 6526a1c
Show file tree
Hide file tree
Showing 15 changed files with 743 additions and 337 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
with:
fetch-depth: 2
- run: pnpm install
- run: pnpm test
- run: pnpm lint
- run: pnpm format:check
- run: cd packages/zod-error-viewer
- run: pnpm test
- run: pnpm build
- name: Publish package
run: |
Expand Down
13 changes: 0 additions & 13 deletions index.html

This file was deleted.

62 changes: 5 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "zod-error-viewer",
"version": "1.2.0",
"name": "zod-error-viewer-monorepo",
"private": true,
"version": "1.0.0",
"license": "MIT",
"author": {
"name": "Ben Lorantfy",
Expand All @@ -10,42 +11,10 @@
"type": "git",
"url": "https://github.com/BenLorantfy/zod-error-viewer"
},
"keywords": [
"zod",
"visualization",
"viewer"
],
"files": [
"dist"
],
"type": "module",
"module": "dist/esm/ZodErrorViewer.js",
"main": "dist/cjs/ZodErrorViewer.js",
"types": "dist/types/ZodErrorViewer.d.ts",
"sideEffects": false,
"exports": {
".": {
"import": "./dist/esm/ZodErrorViewer.js",
"require": "./dist/cjs/ZodErrorViewer.js",
"types": "./dist/types/ZodErrorViewer.d.ts"
}
},
"scripts": {
"dev": "storybook dev -p 6006",
"storybook": "pnpm run dev",
"build": "tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format:check": "prettier --check .",
"build-storybook": "storybook build",
"prepare": "husky",
"test": "vitest"
},
"dependencies": {
"zod": ">=3"
},
"peerDependencies": {
"react": ">=16",
"react-dom": ">=16"
"prepare": "husky"
},
"lint-staged": {
"**/*.{js,ts,tsx,jsx}": [
Expand All @@ -55,19 +24,6 @@
"**/*.json": "prettier --check --ignore-unknown"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.5.0",
"@storybook/addon-essentials": "^8.1.5",
"@storybook/addon-interactions": "^8.1.5",
"@storybook/addon-links": "^8.1.5",
"@storybook/blocks": "^8.1.5",
"@storybook/react": "^8.1.5",
"@storybook/react-vite": "^8.1.5",
"@storybook/test": "^8.1.5",
"@storybook/theming": "^8.1.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
Expand All @@ -76,16 +32,8 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"eslint-plugin-storybook": "^0.8.0",
"happy-dom": "^14.12.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.5",
"prettier": "3.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "^8.1.5",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vitest": "^1.6.0",
"zod": "^3.23.8"
"prettier": "3.3.0"
}
}
204 changes: 204 additions & 0 deletions packages/docs-site/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
// function PlaygroundView() {
// const [dataStr, setDataStr] = useState("");
// const [errorStr, setErrorStr] = useState("");
// const [schemaStr, setSchemaStr] = useState("");

// const { data, dataParseError } = useMemo(() => {
// if (dataStr.trim().length === 0) {
// return {
// data: null,
// };
// }
// try {
// return { data: JSON.parse(dataStr) };
// } catch (err) {
// return {
// data: null,
// dataParseError: err instanceof Error ? err : new Error("Unknown error"),
// };
// }
// }, [dataStr]);

// const { schema, schemaEvalError } = useMemo(() => {
// try {
// Object.assign(window, { z });
// const schema = eval(`const z = window.z; ${schemaStr}`);
// if (!schema || !("_def" in schema)) {
// return {
// schema: null,
// schemaEvalError:
// (schemaStr || "").trim().length > 0
// ? new Error("Missing schema")
// : null,
// };
// }
// return {
// schema,
// schemaEvalError: null,
// };
// } catch (err) {
// return {
// schema: null,
// schemaEvalError:
// err instanceof Error ? err : new Error("Unknown error"),
// };
// }
// }, [schemaStr]);

// const { error, errorParseError, schemaExecuteError } = useMemo(() => {
// if (errorStr.trim().length !== 0) {
// try {
// return { error: JSON.parse(errorStr) };
// } catch (err) {
// return {
// error: undefined,
// errorParseError:
// err instanceof Error ? err : new Error("Unknown error"),
// };
// }
// }

// if (!schema) {
// return {
// error: undefined,
// };
// }

// try {
// return { error: schema.safeParse(data).error };
// } catch (err) {
// return {
// error: undefined,
// schemaExecuteError:
// err instanceof Error ? err : new Error("Unknown error"),
// };
// }
// }, [errorStr, schema, data]);

// return (
// <div className="playground">
// <nav>
// <ul>
// <li>
// <a href="/">
// <span
// style={{
// display: "inline-block",
// height: 0,
// position: "relative",
// top: "-14px",
// }}
// >
// <img
// alt=""
// src={logo}
// height="30px"
// width="71px"
// style={{ verticalAlign: "middle", marginRight: "8px" }}
// />
// </span>
// <span style={{ verticalAlign: "middle" }}>zod-error-viewer</span>
// </a>
// </li>
// <li>
// <a href="/">Docs</a>
// </li>
// <li>
// <a href="/iframe.html?id=zoderrorviewer--playground&viewMode=story">
// Playground
// </a>
// </li>
// </ul>
// </nav>
// <main>
// <h1>Playground</h1>
// <div
// style={{
// display: "flex",
// gap: "8px",
// flexGrow: 0,
// }}
// >
// <section className="editor-column" aria-labelledby="data-heading">
// <div className="editor">
// <h2 id="data-heading">DATA</h2>
// <CodeMirror
// value={dataStr}
// height="300px"
// extensions={[javascript()]}
// onChange={setDataStr}
// />
// </div>
// <div id="data-error" className="error" role="alert">
// {dataParseError?.message
// ? `Failed to parse error: ${dataParseError.message}`
// : ""}
// </div>
// </section>
// <section
// className="editor-column"
// aria-labelledby="error-heading"
// aria-describedby="error-error"
// >
// <div className="editor">
// <h2 id="error-heading">
// <span style={{ verticalAlign: "middle" }}>ERROR</span>{" "}
// <span className="tag">Optional</span>
// </h2>
// <CodeMirror
// value={errorStr}
// height="300px"
// extensions={[javascript()]}
// onChange={setErrorStr}
// />
// </div>
// <div id="error-error" className="error" role="alert">
// {errorParseError?.message
// ? `Failed to parse error: ${errorParseError.message}`
// : ""}
// </div>
// </section>

// <section
// className="editor-column"
// aria-labelledby="schema-heading"
// aria-describedby="schema-eval-error"
// >
// <div className="editor">
// <h2 id="schema-heading">
// <span style={{ verticalAlign: "middle" }}>SCHEMA</span>{" "}
// <span className="tag">Optional</span>
// </h2>
// <CodeMirror
// value={schemaStr}
// height="300px"
// extensions={[javascript()]}
// onChange={setSchemaStr}
// />
// </div>
// <div id="schema-eval-error" className="error" role="alert">
// {schemaExecuteError?.message
// ? `Failed to execute schema: ${schemaExecuteError}`
// : schemaEvalError?.message
// ? `Failed to parse schema: ${schemaEvalError.message}`
// : ""}
// </div>
// </section>
// </div>
// <div className="error-viewer-container editor">
// <h2>ERROR VIEWER</h2>
// <div className="error-viewer">
// <ZodErrorViewer data={data} error={error} height="fill" />
// </div>
// </div>
// </main>
// </div>
// );
// }

// export const Playground: StoryObj = {
// parameters: {
// layout: "fullscreen",
// },
// render: () => <PlaygroundView />,
// };
Loading

0 comments on commit 6526a1c

Please sign in to comment.