diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..93717d6c0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,36 @@ +on: + push: + branches: [main] + +name: CI Typecheck and Lint + +jobs: + build: + name: Lint and Typecheck + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + lfs: true + - name: Checkout LFS objects + run: git lfs checkout + + - uses: pnpm/action-setup@v4.0.0 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + - name: Install dependencies + run: pnpm install + - name: Lint and Typecheck + + run: | + pnpm run typecheck && npm run lint diff --git a/package.json b/package.json index f5238dff6..2fcf1a83c 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "electron-updater": "^6.1.7", "framer-motion": "11.2.6", "hast-util-to-jsx-runtime": "2.3.0", + "immer": "10.1.1", "jotai": "2.8.1", "jotai-dark": "^0.3.0", "jotai-effect": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4dc382523..0e728280e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,6 +101,9 @@ importers: hast-util-to-jsx-runtime: specifier: 2.3.0 version: 2.3.0 + immer: + specifier: 10.1.1 + version: 10.1.1 jotai: specifier: 2.8.1 version: 2.8.1(@types/react@18.3.3)(react@18.3.1) @@ -160,7 +163,7 @@ importers: version: 3.23.8 zustand: specifier: 4.5.2 - version: 4.5.2(@types/react@18.3.3)(react@18.3.1) + version: 4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1) devDependencies: '@egoist/tailwindcss-icons': specifier: 1.8.0 @@ -3094,6 +3097,7 @@ packages: glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} + deprecated: Glob versions prior to v9 are no longer supported global-agent@3.0.0: resolution: {integrity: sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==} @@ -3283,6 +3287,9 @@ packages: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} + immer@10.1.1: + resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==} + import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -4418,6 +4425,7 @@ packages: rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true roarr@2.15.4: @@ -8767,6 +8775,8 @@ snapshots: ignore@5.3.1: {} + immer@10.1.1: {} + import-fresh@3.3.0: dependencies: parent-module: 1.0.1 @@ -10602,11 +10612,12 @@ snapshots: zod@3.23.8: {} - zustand@4.5.2(@types/react@18.3.3)(react@18.3.1): + zustand@4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1): dependencies: use-sync-external-store: 1.2.0(react@18.3.1) optionalDependencies: '@types/react': 18.3.3 + immer: 10.1.1 react: 18.3.1 zwitch@2.0.4: {} diff --git a/src/renderer/src/biz/error.ts b/src/renderer/src/biz/error.ts new file mode 100644 index 000000000..e42fad4a5 --- /dev/null +++ b/src/renderer/src/biz/error.ts @@ -0,0 +1,18 @@ +export abstract class RequestError extends Error { + name = "RequestError" +} +export class UnAuthorizedError extends RequestError { + name = "UnAuthorizedError" + + constructor(message?: string) { + super(message) + } +} + +export class UnprocessableEntityError extends RequestError { + name = "UnprocessableEntityError" + + constructor(message?: string) { + super(message) + } +} diff --git a/src/renderer/src/components/Versions.tsx b/src/renderer/src/components/Versions.tsx index 8de714338..54314fdd7 100644 --- a/src/renderer/src/components/Versions.tsx +++ b/src/renderer/src/components/Versions.tsx @@ -1,8 +1,10 @@ +import type { ReactNode } from "react" import { useState } from "react" -function Versions(): JSX.Element { - const [versions] = useState(window.electron.process.versions) +function Versions(): ReactNode { + const [versions] = useState(window.electron?.process.versions) + if (!versions) return null return (