Connect, collaborate, and grow with a community of TypeScript developers
Chore: Setup sherif (#1530)
Shane Walkerd4f04f37f02e
diff --git a/.env.example b/.env.exampleindex f9bbda55..9f6ecac0 100644--- a/.env.example+++ b/.env.example@@ -16,3 +16,7 @@ NEXTAUTH_URL="http://localhost:3000"NEXT_PUBLIC_ALGOLIA_APP_ID=NEXT_PUBLIC_ALGOLIA_API_KEY=+# AOT Github ID and Secret+GITHUB_AOT_ID=asdf+GITHUB_AOT_SECRET=asdf+diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.ymlindex d30180ce..87f2e341 100644--- a/.github/workflows/quality.yml+++ b/.github/workflows/quality.yml@@ -69,6 +69,19 @@ jobs:- name: Run TypeScript type checkrun: turbo typecheck --continue+ sherif:+ name: Sherif+ needs: typecheck+ runs-on: ubuntu-latest+ steps:+ - name: Checkout+ uses: actions/checkout@v3++ - name: Install+ uses: ./tooling/github-actions/install++ - name: Run Sherif+ run: pnpm package-checke2e:name: E2Etimeout-minutes: 30diff --git a/LOCAL.md b/LOCAL.mdindex 35a51bcb..6276b80c 100644--- a/LOCAL.md+++ b/LOCAL.md@@ -65,6 +65,8 @@ UPLOADTHING_APP_ID="very_real_uploadthing_app_id"# https://next-auth.js.org/configuration/options#secretNEXTAUTH_SECRET="for local use you can just use a garble of letters"NEXTAUTH_URL="http://localhost:3000"+GITHUB_AOT_ID=asdf+GITHUB_AOT_SECRET=asdf```### 5. Setup algolia for searchdiff --git a/apps/admin/package.json b/apps/admin/package.jsonindex 85f466df..6730e2f7 100644--- a/apps/admin/package.json+++ b/apps/admin/package.json@@ -50,7 +50,7 @@"eslint": "^8.45.0","eslint-config-next": "^13.4.10","eslint-plugin-import": "^2.27.5",- "postcss": "^8.4.26",+ "postcss": "^8.4.31","prettier": "^3.1.1","prettier-plugin-tailwindcss": "^0.5.9","raw-loader": "^4.0.2",diff --git a/apps/admin/src/app/dashboard/reports/[id]/_components/extra-actions.report.tsx b/apps/admin/src/app/dashboard/reports/[id]/_components/extra-actions.report.tsxnew file mode 100644index 00000000..f4ff5fbd--- /dev/null+++ b/apps/admin/src/app/dashboard/reports/[id]/_components/extra-actions.report.tsx@@ -0,0 +1,84 @@+import type { ReportWithInfo } from '../_actions';+import { Button } from '@repo/ui/components/button';+import { toast } from '@repo/ui/components/use-toast';+import router from 'next/router';+import { banChallenge, deleteComment, deleteSolution } from '../_actions';++export const ExtraActionsButton = ({ report }: { report: ReportWithInfo }) => {+ async function handleDeleteComment(commentId: number, reportId: number) {+ try {+ await deleteComment(commentId, reportId);+ toast({+ title: 'Success',+ description: <p>Comment deleted successfully</p>,+ });+ router.push('/?tab=reports');+ } catch (e) {+ toast({+ title: 'Error',+ variant: 'destructive',+ description: <p>An error occurred. Please try again later.</p>,+ });+ }+ }+ async function handleDisableChallenge(challengeId: number, reportId: number) {+ try {+ await banChallenge(challengeId, reportId);+ router.push('/?tab=reports');+ } catch (e) {+ toast({+ title: 'Error',+ variant: 'destructive',+ description: <p>An error occurred. Please try again later</p>,+ });+ }+ }+ async function handleRemoveSolution(solutionId: number) {+ const response = await deleteSolution(solutionId, report.id);+ if (response === 'ok') {+ toast({+ title: 'Successfully removed solution',+ });+ router.push('/?tab=reports');+ } else {+ toast({+ title: 'Error',+ description: <p>Something has gone wrong. Please try again later.</p>,+ });+ }+ }+ switch (report.type) {+ case 'CHALLENGE':+ return (+ <Button+ disabled={report.moderatorId !== null}+ onClick={() => handleDisableChallenge(report.challengeId!, report.id)}+ >+ Disable Challenge+ </Button>+ );++ case 'SOLUTION':+ return (+ <Button+ disabled={report.moderator !== null}+ onClick={() => handleRemoveSolution(report.solutionId!)}+ >+ Remove Solution+ </Button>+ );++ case 'COMMENT':+ return (+ <Button+ disabled={report.moderatorId !== null}+ onClick={() => handleDeleteComment(report.commentId!, report.id)}+ variant="destructive"+ >+ Delete Comment+ </Button>+ );+ default:+ return null;+ }+};diff --git a/apps/admin/src/app/dashboard/reports/[id]/actions.tsx b/apps/admin/src/app/dashboard/reports/[id]/actions.tsxindex 3f3cb096..a83962b4 100644--- a/apps/admin/src/app/dashboard/reports/[id]/actions.tsx+++ b/apps/admin/src/app/dashboard/reports/[id]/actions.tsx@@ -1,6 +1,6 @@'use client';-import { type User } from '@repo/db/types';+import type { User } from '@repo/db/types';import { Button } from '@repo/ui/components/button';import {Dialog,@@ -16,7 +16,8 @@ import { toast } from '@repo/ui/components/use-toast';import { useRouter } from 'next/navigation';import { useMemo, useState } from 'react';import type { ReportWithInfo } from './_actions';-import { banChallenge, banUser, deleteComment, deleteSolution, dismissReport } from './_actions';+import { banUser, dismissReport } from './_actions';+import { ExtraActionsButton } from './_components/extra-actions.report';export interface ReportActionsProps {report: NonNullable<ReportWithInfo>;@@ -45,36 +46,6 @@ export function ReportActions({ report }: ReportActionsProps) {}}, [report]);- async function handleDeleteComment(commentId: number, reportId: number) {- try {- await deleteComment(commentId, reportId);- toast({- title: 'Success',- description: <p>Comment deleted successfully</p>,- });- router.push('/?tab=reports');- } catch (e) {- toast({- title: 'Error',- variant: 'destructive',- description: <p>An error occurred. Please try again later.</p>,- });- }- }-- async function handleDisableChallenge(challengeId: number, reportId: number) {- try {- await banChallenge(challengeId, reportId);- router.push('/?tab=reports');- } catch (e) {- toast({- title: 'Error',- variant: 'destructive',- description: <p>An error occurred. Please try again later</p>,- });- }- }-async function handleBanUser(userId: string, reportId: number, banReason?: string) {try {await banUser(report.userId!, reportId, banReason);@@ -110,21 +81,6 @@ export function ReportActions({ report }: ReportActionsProps) {}}- async function handleRemoveSolution(solutionId: number) {- const response = await deleteSolution(solutionId, report.id);- if (response === 'ok') {- toast({- title: 'Successfully removed solution',- });- router.push('/?tab=reports');- } else {- toast({- title: 'Error',- description: <p>Something has gone wrong. Please try again later.</p>,- });- }- }-return (<div className="flex gap-2"><Button@@ -135,33 +91,7 @@ export function ReportActions({ report }: ReportActionsProps) {Ban @{user?.name ?? 'unknown user'}</Button>- {report.type === 'CHALLENGE' && (- <Button- disabled={report.moderatorId !== null}- onClick={() => handleDisableChallenge(report.challengeId!, report.id)}- >- Disable Challenge- </Button>- )}-- {report.type === 'SOLUTION' && (- <Button- disabled={report.moderator !== null}- onClick={() => handleRemoveSolution(report.solutionId!)}- >- Remove Solution- </Button>- )}-- {report.type === 'COMMENT' && (- <Button- disabled={report.moderatorId !== null}- onClick={() => handleDeleteComment(report.commentId!, report.id)}- variant="destructive"- >- Delete Comment- </Button>- )}+ <ExtraActionsButton report={report} /><Button disabled={report.moderatorId !== null} onClick={() => handleDismissReport(report.id)}>Dismiss Reportdiff --git a/apps/aot/src/server/auth.ts b/apps/aot/src/server/auth.tsindex 9b10f816..45af0668 100644--- a/apps/aot/src/server/auth.ts+++ b/apps/aot/src/server/auth.ts@@ -7,7 +7,7 @@ if (!process.env.GITHUB_AOT_ID) {}if (!process.env.GITHUB_AOT_SECRET) {- throw new Error('No GITHUB__AOT_SECRET has been provided.');+ throw new Error('No GITHUB_AOT_SECRET has been provided.');}export const authOptions = {diff --git a/apps/auth-proxy/package.json b/apps/auth-proxy/package.jsonindex 5b3d2236..af43a2b7 100644--- a/apps/auth-proxy/package.json+++ b/apps/auth-proxy/package.json@@ -18,7 +18,7 @@"devDependencies": {"@repo/lint": "workspace:*","@repo/tsconfig": "workspace:*",- "eslint": "^8.56.0",+ "eslint": "^8.45.0","nitropack": "^2.8.1","prettier": "^3.1.1","typescript": "^5.3.3"diff --git a/apps/web/package.json b/apps/web/package.jsonindex 67e4afc4..097a86a7 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -71,7 +71,7 @@"react-wrap-balancer": "^1.0.0","remark-gfm": "^3.0.1","resend": "^0.17.2",- "superjson": "1.12.4",+ "superjson": "^2.2.1","tailwindcss-animate": "^1.0.6","unified": "^10.1.2","unist-util-visit": "^5.0.0",@@ -95,7 +95,7 @@"eslint": "^8.45.0","eslint-config-next": "^13.4.10","eslint-plugin-import": "^2.27.5",- "postcss": "^8.4.26",+ "postcss": "^8.4.31","prettier": "^3.1.1","prettier-plugin-tailwindcss": "^0.5.9","raw-loader": "^4.0.2",diff --git a/package.json b/package.jsonindex 24b10158..61fa2de6 100644--- a/package.json+++ b/package.json@@ -22,6 +22,7 @@"lint:markdown": "markdownlint-cli2 \"challenges/**/*.md\" \"#**/node_modules\" && cspell challenges/** --no-progress","lint:markdown:validate": "tsx challenges/validate.ts","lint:fix": "eslint . --fix --cache --cache-location \"node_modules/.cache/.eslintcache\" --max-warnings 0",+ "package-check": "pnpm dlx sherif@latest --ignore-rule root-package-dependencies","refresh": "turbo db:reset db:seed --concurrency=1","test:e2e": "turbo test:e2e","test:e2e:install": "playwright install",diff --git a/packages/monaco/package.json b/packages/monaco/package.jsonindex 2f724497..c157a441 100644--- a/packages/monaco/package.json+++ b/packages/monaco/package.json@@ -60,7 +60,7 @@"next": "14.2.5","next-themes": "^0.2.1","prettier": "^3.1.1",- "react": "^18.2.0",+ "react": "18.2.0","react-hook-form": "^7.45.1","zustand": "^4.3.9"},diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex aac7da82..726c6af5 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -59,7 +59,7 @@"lucide-react": "^0.260.0","next-themes": "^0.2.1","mdast-util-find-and-replace": "^3.0.1",- "react": "^18.2.0",+ "react": "18.2.0","react-day-picker": "^8.8.0","react-hook-form": "^7.45.1","react-markdown": "^8.0.7",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 75017de2..e42d2ef8 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -149,7 +149,7 @@ importers:version: 15.5.7autoprefixer:specifier: ^10.4.14- version: 10.4.14([email protected])+ version: 10.4.14([email protected])dotenv:specifier: ^16.3.1version: 16.3.1@@ -163,8 +163,8 @@ importers:specifier: ^2.27.5version: 2.27.5(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])postcss:- specifier: ^8.4.26- version: 8.4.26+ specifier: ^8.4.31+ version: 8.4.31prettier:specifier: ^3.1.1version: 3.1.1@@ -291,7 +291,7 @@ importers:specifier: workspace:*version: link:../../tooling/config-typescripteslint:- specifier: ^8.56.0+ specifier: ^8.45.0version: 8.56.0nitropack:specifier: ^2.8.1@@ -499,8 +499,8 @@ importers:specifier: ^0.17.2version: 0.17.2superjson:- specifier: 1.12.4- version: 1.12.4+ specifier: ^2.2.1+ version: 2.2.1tailwindcss-animate:specifier: ^1.0.6version: 1.0.6([email protected])@@ -552,7 +552,7 @@ importers:version: 15.5.7autoprefixer:specifier: ^10.4.14- version: 10.4.14([email protected])+ version: 10.4.14([email protected])dotenv:specifier: ^16.3.1version: 16.3.1@@ -566,8 +566,8 @@ importers:specifier: ^2.27.5version: 2.27.5(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])postcss:- specifier: ^8.4.26- version: 8.4.26+ specifier: ^8.4.31+ version: 8.4.31prettier:specifier: ^3.1.1version: 3.1.1@@ -703,7 +703,7 @@ importers:specifier: ^3.1.1version: 3.1.1react:- specifier: ^18.2.0+ specifier: 18.2.0version: 18.2.0react-hook-form:specifier: ^7.45.1@@ -809,7 +809,7 @@ importers:specifier: ^0.2.1version: 0.2.1([email protected]([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])react:- specifier: ^18.2.0+ specifier: 18.2.0version: 18.2.0react-day-picker:specifier: ^8.8.0@@ -859,7 +859,7 @@ importers:dependencies:'@next/eslint-plugin-next':specifier: canary- version: 15.0.0-canary.134+ version: 15.0.0-canary.135'@repo/tsconfig':specifier: workspace:*version: link:../config-typescript@@ -871,7 +871,7 @@ importers:version: 5.62.0([email protected])([email protected])'@vercel/style-guide':specifier: ^4.0.2eslint:specifier: ^8.45.0version: 8.45.0@@ -897,6 +897,8 @@ importers:tooling/config-typescript: {}+ tooling/github-actions: {}+tooling/scripts:devDependencies:'@repo/lint':@@ -1951,8 +1953,8 @@ packages:'@next/[email protected]':resolution: {integrity: sha512-YJqyq6vk39JQfvaNtN83t/p5Jy45+bazRL+V4QI8FPd3FBqFYMEsULiwRLgSJMgFqkk4t4JbeZurz+gILEAFpA==}- '@next/[email protected]':- resolution: {integrity: sha512-q2UuxIGXH+6vYawpEz78/YLIWlkIjRmsJPr9AQPUo+zYySUlaTKzJvalEG56i+wUDy/lfjzG5F0MiJeDR/RHiA==}+ '@next/[email protected]':+ resolution: {integrity: sha512-0JBroVa+Z7H3EzvnUAP5PgN0vLGgftEjkDlNbbH2GA4lGNzLB4eb/oXwL1bk+8BAoh9HMhY5MeWUizIDQ/dU4w==}'@next/[email protected]':resolution: {integrity: sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==}@@ -6803,10 +6805,6 @@ packages:resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}- resolution: {integrity: sha512-jrXHFF8iTloAenySjM/ob3gSj7pCu0Ji49hnjqzsgSRa50hkWCKD0HQ+gMNJkW38jBI68MpAAg7ZWwHwX8NMMw==}- engines: {node: ^10 || ^12 || >=14}-resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}engines: {node: ^10 || ^12 || >=14}@@ -7595,10 +7593,6 @@ packages:engines: {node: '>= 4.0'}deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.- resolution: {integrity: sha512-vkpPQAxdCg9SLfPv5GPC5fnGrui/WryktoN9O5+Zif/14QIMjw+RITf/5LbBh+9QpBFb3KNvJth+puz2H8o6GQ==}- engines: {node: '>=10'}-resolution: {integrity: sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==}engines: {node: '>=16'}@@ -9227,7 +9221,7 @@ snapshots:dependencies:glob: 7.1.7- '@next/[email protected]':+ '@next/[email protected]':dependencies:fast-glob: 3.3.1@@ -11226,7 +11220,7 @@ snapshots:next: 14.2.5(@playwright/[email protected])([email protected]([email protected]))([email protected])react: 18.2.0- '@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected])':+ '@vercel/[email protected](@next/[email protected])([email protected])([email protected])([email protected])':dependencies:'@babel/core': 7.22.10'@babel/eslint-parser': 7.22.10(@babel/[email protected])([email protected])@@ -11248,7 +11242,7 @@ snapshots:eslint-plugin-unicorn: 43.0.2([email protected])prettier-plugin-packagejson: 2.4.3([email protected])optionalDependencies:- '@next/eslint-plugin-next': 15.0.0-canary.134+ '@next/eslint-plugin-next': 15.0.0-canary.135eslint: 8.45.0prettier: 3.1.1typescript: 5.3.3@@ -11565,16 +11559,6 @@ snapshots:- dependencies:- browserslist: 4.22.2- caniuse-lite: 1.0.30001599- fraction.js: 4.2.0- normalize-range: 0.1.2- picocolors: 1.0.0- postcss: 8.4.26- postcss-value-parser: 4.2.0-dependencies:browserslist: 4.22.2@@ -15151,12 +15135,6 @@ snapshots:- dependencies:- nanoid: 3.3.6- picocolors: 1.0.0- source-map-js: 1.0.2-dependencies:nanoid: 3.3.6@@ -16041,10 +16019,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- copy-anything: 3.0.5-dependencies:copy-anything: 3.0.5diff --git a/tooling/github-actions/package.json b/tooling/github-actions/package.jsonnew file mode 100644index 00000000..7b4af217--- /dev/null+++ b/tooling/github-actions/package.json@@ -0,0 +1,5 @@+{+ "name": "github-actions",+ "version": "0.0.0",+ "private": true+}\ No newline at end of file