diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3db2e79..57f0231 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -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, }, }; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index de92157..c3c753a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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" @@ -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 @@ -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 diff --git a/img/logo-wide.png b/img/logo-wide.png deleted file mode 100644 index 9fb2bb3..0000000 Binary files a/img/logo-wide.png and /dev/null differ diff --git a/package.json b/package.json index 2abfcf8..a4e3f66 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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}": [ @@ -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", @@ -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" } } diff --git a/packages/docs-site/README.md b/packages/docs-site/README.md new file mode 100644 index 0000000..bb15685 --- /dev/null +++ b/packages/docs-site/README.md @@ -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 diff --git a/index.html b/packages/docs-site/index.html similarity index 72% rename from index.html rename to packages/docs-site/index.html index e4b78ea..842afe5 100644 --- a/index.html +++ b/packages/docs-site/index.html @@ -2,9 +2,9 @@ - + - Vite + React + TS + zod-error-viewer
diff --git a/packages/docs-site/package.json b/packages/docs-site/package.json new file mode 100644 index 0000000..a1597e7 --- /dev/null +++ b/packages/docs-site/package.json @@ -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" + } +} diff --git a/packages/docs-site/public/favicon.svg b/packages/docs-site/public/favicon.svg new file mode 100644 index 0000000..7be4ed1 --- /dev/null +++ b/packages/docs-site/public/favicon.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/docs-site/src/App.tsx b/packages/docs-site/src/App.tsx new file mode 100644 index 0000000..9d50e8e --- /dev/null +++ b/packages/docs-site/src/App.tsx @@ -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 ( + + + + + + + + + +