Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Chore: Setup sherif (#1530)

Shane Walkerd4f04f37f02e
diff --git a/.env.example b/.env.example
index 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.yml
index d30180ce..87f2e341 100644
--- a/.github/workflows/quality.yml
+++ b/.github/workflows/quality.yml
@@ -69,6 +69,19 @@ jobs:
- name: Run TypeScript type check
run: 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-check
e2e:
name: E2E
timeout-minutes: 30
diff --git a/LOCAL.md b/LOCAL.md
index 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#secret
NEXTAUTH_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 search
diff --git a/apps/admin/package.json b/apps/admin/package.json
index 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.tsx
new file mode 100644
index 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.tsx
index 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 Report
diff --git a/apps/aot/src/server/auth.ts b/apps/aot/src/server/auth.ts
index 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.json
index 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.json
index 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.json
index 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.json
index 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.json
index 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.yaml
index 75017de2..e42d2ef8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -149,7 +149,7 @@ importers:
version: 15.5.7
autoprefixer:
specifier: ^10.4.14
- version: 10.4.14([email protected])
+ version: 10.4.14([email protected])
dotenv:
specifier: ^16.3.1
version: 16.3.1
@@ -163,8 +163,8 @@ importers:
specifier: ^2.27.5
postcss:
- specifier: ^8.4.26
- version: 8.4.26
+ specifier: ^8.4.31
+ version: 8.4.31
prettier:
specifier: ^3.1.1
version: 3.1.1
@@ -291,7 +291,7 @@ importers:
specifier: workspace:*
version: link:../../tooling/config-typescript
eslint:
- specifier: ^8.56.0
+ specifier: ^8.45.0
version: 8.56.0
nitropack:
specifier: ^2.8.1
@@ -499,8 +499,8 @@ importers:
specifier: ^0.17.2
version: 0.17.2
superjson:
- specifier: 1.12.4
- version: 1.12.4
+ specifier: ^2.2.1
+ version: 2.2.1
tailwindcss-animate:
specifier: ^1.0.6
version: 1.0.6([email protected])
@@ -552,7 +552,7 @@ importers:
version: 15.5.7
autoprefixer:
specifier: ^10.4.14
- version: 10.4.14([email protected])
+ version: 10.4.14([email protected])
dotenv:
specifier: ^16.3.1
version: 16.3.1
@@ -566,8 +566,8 @@ importers:
specifier: ^2.27.5
postcss:
- specifier: ^8.4.26
- version: 8.4.26
+ specifier: ^8.4.31
+ version: 8.4.31
prettier:
specifier: ^3.1.1
version: 3.1.1
@@ -703,7 +703,7 @@ importers:
specifier: ^3.1.1
version: 3.1.1
react:
- specifier: ^18.2.0
+ specifier: 18.2.0
version: 18.2.0
react-hook-form:
specifier: ^7.45.1
@@ -809,7 +809,7 @@ importers:
specifier: ^0.2.1
react:
- specifier: ^18.2.0
+ specifier: 18.2.0
version: 18.2.0
react-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:
'@vercel/style-guide':
specifier: ^4.0.2
eslint:
specifier: ^8.45.0
version: 8.45.0
@@ -897,6 +897,8 @@ importers:
tooling/config-typescript: {}
+ tooling/github-actions: {}
+
tooling/scripts:
devDependencies:
'@repo/lint':
@@ -1951,8 +1953,8 @@ packages:
resolution: {integrity: sha512-YJqyq6vk39JQfvaNtN83t/p5Jy45+bazRL+V4QI8FPd3FBqFYMEsULiwRLgSJMgFqkk4t4JbeZurz+gILEAFpA==}
- resolution: {integrity: sha512-q2UuxIGXH+6vYawpEz78/YLIWlkIjRmsJPr9AQPUo+zYySUlaTKzJvalEG56i+wUDy/lfjzG5F0MiJeDR/RHiA==}
+ resolution: {integrity: sha512-0JBroVa+Z7H3EzvnUAP5PgN0vLGgftEjkDlNbbH2GA4lGNzLB4eb/oXwL1bk+8BAoh9HMhY5MeWUizIDQ/dU4w==}
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
dependencies:
fast-glob: 3.3.1
@@ -11226,7 +11220,7 @@ snapshots:
react: 18.2.0
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.135
eslint: 8.45.0
prettier: 3.1.1
typescript: 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.5
diff --git a/tooling/github-actions/package.json b/tooling/github-actions/package.json
new file mode 100644
index 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