Skip to content

Commit

Permalink
Fix bug with missing discriminator, add playground page, restructure …
Browse files Browse the repository at this point in the history
…to monorepo, misc other changes (#2)
  • Loading branch information
BenLorantfy committed Jul 14, 2024
1 parent ac1a6aa commit f4ddc74
Show file tree
Hide file tree
Showing 36 changed files with 1,407 additions and 195 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react-refresh/only-export-components": 0,
},
};
24 changes: 20 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ jobs:
with:
fetch-depth: 2
- run: pnpm install
- run: pnpm test
- run: pnpm lint
- run: pnpm format:check
- run: pnpm test
working-directory: packages/zod-error-viewer
- run: pnpm build
working-directory: packages/zod-error-viewer
- name: Publish package
working-directory: packages/zod-error-viewer
run: |
if [ $GITHUB_REF != "refs/heads/main" ]; then
echo "Branch is not main, skipping publish step"
Expand All @@ -27,7 +30,7 @@ jobs:
echo "Branch is main, proceeding..."
prev_version=$(git show HEAD~1:package.json | jq -r '.version')
prev_version=$(git show HEAD~1:packages/zod-error-viewer/package.json | jq -r '.version')
new_version=$(cat package.json | jq -r '.version')
if [ $prev_version = $new_version ]; then
Expand All @@ -43,11 +46,24 @@ jobs:
echo "Publishing package..."
pnpm publish
- name: Build documentation
- name: Build storybook
working-directory: packages/zod-error-viewer
run: pnpm build-storybook
- name: Build docs site
working-directory: packages/docs-site
run: pnpm build
- name: Move storybook to under docs site
run: mv ./packages/zod-error-viewer/storybook-static ./packages/docs-site/dist/storybook-static
# Workaround since github pages does not support routing all requests to index.html
- name: Create fake pages
run: |
mkdir ./packages/docs-site/dist/docs
cp ./packages/docs-site/dist/index.html ./packages/docs-site/dist/docs/index.html
mkdir ./packages/docs-site/dist/playground
cp ./packages/docs-site/dist/index.html ./packages/docs-site/dist/playground/index.html
- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v3
with:
path: storybook-static
path: packages/docs-site/dist
- name: Publish documentation
uses: actions/deploy-pages@v4
Binary file removed img/logo-wide.png
Binary file not shown.
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.1",
"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"
}
}
30 changes: 30 additions & 0 deletions packages/docs-site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname,
},
};
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
4 changes: 2 additions & 2 deletions index.html → packages/docs-site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>zod-error-viewer</title>
</head>
<body>
<div id="root"></div>
Expand Down
26 changes: 26 additions & 0 deletions packages/docs-site/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "docs-site",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@codemirror/lang-javascript": "^6.2.2",
"@uiw/react-codemirror": "^4.22.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"zod": ">=3",
"zod-error-viewer": "workspace:*"
},
"devDependencies": {
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
}
67 changes: 67 additions & 0 deletions packages/docs-site/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions packages/docs-site/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PlaygroundPage } from "./pages/PlaygroundPage";
import { Route, Router } from "./components/Router";
import { HomePage } from "./pages/HomePage";
import { Layout } from "./components/Layout";

export function App() {
return (
<Router>
<Layout>
<Route path="/">
<HomePage />
</Route>
<Route path="/playground">
<PlaygroundPage />
</Route>
<Route path="/docs">
<iframe
src="/storybook-static"
style={{ width: "100%", height: "100%", border: 0 }}
/>
</Route>
</Layout>
</Router>
);
}
Binary file added packages/docs-site/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions packages/docs-site/src/components/Layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.content {
height: 100%;
display: flex;
flex-direction: column;
}

main {
flex-grow: 1;
flex-basis: 0;
}

nav {
background-color: rgb(247, 249, 252);
flex-grow: 0;
display: flex;
border-bottom: 1px solid rgb(220, 220, 220);

ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;

li {
height: 100%;

a {
padding: 16px;
display: flex;
align-items: center;
text-decoration: none;
color: #595959;
transition: all 0.1s;
}

a:hover {
background-color: #e7e7e7;
}

a:focus {
background-color: #e7e7e7;
}

a:active {
background-color: #dddddd;
}

a[aria-current="page"] {
background-color: #dddddd;
}
}
}
}
Loading

0 comments on commit f4ddc74

Please sign in to comment.