Skip to content

Commit

Permalink
Merge branch 'main' into jacek/backend-vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jacekradko committed Oct 25, 2024
2 parents f1a2dcf + abeb659 commit d2a477f
Show file tree
Hide file tree
Showing 278 changed files with 7,810 additions and 3,280 deletions.
File renamed without changes.
5 changes: 0 additions & 5 deletions .changeset/lemon-terms-begin.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/little-adults-end.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/neat-wasps-explain.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/olive-trainers-heal.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/wise-onions-double.md

This file was deleted.

19 changes: 16 additions & 3 deletions .github/workflows/major-version-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Major Version Check

on:
workflow_dispatch:
pull_request:
types: [opened, edited, synchronize]
issue_comment:
Expand All @@ -20,7 +21,7 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const prNumber = context.payload?.pull_request?.number || context.payload?.issue?.number;
// Get list of files changed in the PR
const { data: files } = await github.rest.pulls.listFiles({
Expand All @@ -29,6 +30,18 @@ jobs:
pull_number: prNumber,
});
let pullRequest = context.payload.pull_request;
if (!pullRequest) {
// Fetch the pull request data
const pullRequestData = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
pullRequest = pullRequestData.data;
}
// Check if any changeset files indicate a major bump
let hasMajorChangeset = false;
for (const file of files) {
Expand All @@ -38,7 +51,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
path: file.filename,
ref: context.payload.pull_request.head.sha,
ref: pullRequest.head.sha,
});
const content = Buffer.from(changesetContent.content, changesetContent.encoding).toString();
Expand All @@ -58,7 +71,7 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const prNumber = context.payload?.pull_request?.number || context.payload?.issue?.number;
const org = context.repo.owner;
// Get all comments on the PR
Expand Down
8 changes: 4 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"printWidth": 120,
"singleAttributePerLine": true,
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxSingleQuote": true,
"plugins": ["prettier-plugin-packagejson", "prettier-plugin-tailwindcss"],
"printWidth": 120,
"semi": true,
"singleAttributePerLine": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"plugins": ["prettier-plugin-tailwindcss"]
"trailingComma": "all"
}
10 changes: 5 additions & 5 deletions integration/templates/astro-hybrid/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "astro-clerk-hybrid-playground",
"type": "module",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "astro dev",
"start": "astro dev --port $PORT",
"astro": "astro",
"build": "astro check && astro build",
"dev": "astro dev",
"preview": "astro preview --port $PORT",
"astro": "astro"
"start": "astro dev --port $PORT"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/react": "^3.6.2",
"@astrojs/node": "^8.3.4",
"@astrojs/react": "^3.6.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"astro": "^4.15.11",
Expand Down
10 changes: 5 additions & 5 deletions integration/templates/astro-node/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "astro-clerk-playground",
"type": "module",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "astro dev",
"start": "astro dev --port $PORT",
"astro": "astro",
"build": "astro check && astro build",
"dev": "astro dev",
"preview": "astro preview --port $PORT",
"astro": "astro"
"start": "astro dev --port $PORT"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/node": "^8.3.4",
"@astrojs/react": "^3.6.2",
"@astrojs/tailwind": "^5.1.1",
"@astrojs/node": "^8.3.4",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"astro": "^4.15.11",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
import { ViewTransitions } from 'astro:transitions';
interface Props {
title: string;
}
const { title } = Astro.props;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<ViewTransitions />
</head>
<body>
<main>
<slot />
</main>
</body>
</html>
15 changes: 15 additions & 0 deletions integration/templates/astro-node/src/pages/transitions/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
import { SignedIn, SignedOut, UserButton } from "@clerk/astro/components";
import Layout from "../../layouts/ViewTransitionsLayout.astro";
---

<Layout title="Sign in">
<div class="w-full flex justify-center">
<SignedOut>
<a href="/transitions/sign-in">Sign in</a>
</SignedOut>
<SignedIn>
<UserButton />
</SignedIn>
</div>
</Layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
import { SignIn } from "@clerk/astro/components";
import Layout from "../../layouts/ViewTransitionsLayout.astro";
---

<Layout title="Sign in">
<div class="w-full flex justify-center">
<SignIn forceRedirectUrl="/transitions" />
</div>
</Layout>
16 changes: 8 additions & 8 deletions integration/templates/expo-web/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "expo-web",
"main": "expo-router/entry",
"version": "1.0.0",
"private": true,
"main": "expo-router/entry",
"scripts": {
"dev": "RCT_METRO_PORT=$PORT expo start --web --port $PORT",
"build": "expo export -p web",
"start": "npx serve dist --single",
"lint": "expo lint"
"dev": "RCT_METRO_PORT=$PORT expo start --web --port $PORT",
"lint": "expo lint",
"start": "npx serve dist --single"
},
"jest": {
"preset": "jest-expo"
Expand All @@ -30,8 +31,8 @@
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.9",
"react-native-screens": "~3.31.1",
"react-native-web": "~0.19.6",
"react-native-url-polyfill": "^2.0.0"
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand All @@ -42,6 +43,5 @@
"jest-expo": "~51.0.3",
"react-test-renderer": "18.2.0",
"typescript": "~5.6.2"
},
"private": true
}
}
4 changes: 2 additions & 2 deletions integration/templates/next-app-router/src/app/api/me/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { auth } from '@clerk/nextjs/server';

export function GET() {
const { userId } = auth();
export async function GET() {
const { userId } = await auth();
return new Response(JSON.stringify({ userId }));
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { auth } from '@clerk/nextjs/server';

export function GET() {
const { userId } = auth().protect(has => has({ role: 'admin' }) || has({ role: 'org:editor' }));
export async function GET() {
const { userId } = await auth.protect((has: any) => has({ role: 'admin' }) || has({ role: 'org:editor' }));
return new Response(JSON.stringify({ userId }));
}
6 changes: 4 additions & 2 deletions integration/templates/next-app-router/src/app/csp/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { headers } from 'next/headers';
import { ClerkLoaded } from '@clerk/nextjs';

export default function CSPPage() {
export default async function CSPPage() {
const cspHeader = await headers().get('Content-Security-Policy');

return (
<div>
CSP: <pre>{headers().get('Content-Security-Policy')}</pre>
CSP: <pre>{cspHeader}</pre>
<ClerkLoaded>
<p>clerk loaded</p>
</ClerkLoaded>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>User is admin</div>;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Home({ params }: { params: { id: string } }) {
const { orgId } = auth();
export default async function Home({ params }: { params: { id: string } }) {
const { orgId } = await auth();

if (params.id != orgId) {
console.log('Mismatch - returning nothing for now...', params.id, orgId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Home({ params }: { params: { id: string } }) {
const { orgId } = auth();
export default async function Home({ params }: { params: { id: string } }) {
const { orgId } = await auth();

if (params.id != orgId) {
console.log('Mismatch - returning nothing for now...', params.id, orgId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Home({ params }: { params: { slug: string } }) {
const { orgSlug } = auth();
export default async function Home({ params }: { params: { slug: string } }) {
const { orgSlug } = await auth();

if (params.slug != orgSlug) {
console.log('Mismatch - returning nothing for now...', params.slug, orgSlug);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Home({ params }: { params: { slug: string } }) {
const { orgSlug } = auth();
export default async function Home({ params }: { params: { slug: string } }) {
const { orgSlug } = await auth();

if (params.slug != orgSlug) {
console.log('Mismatch - returning nothing for now...', params.slug, orgSlug);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Page() {
auth().protect();
export default async function Page() {
await auth.protect();

return <div>Protected Page</div>;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Home(): {} {
const { orgId } = auth();
export default async function Home() {
const { orgId } = await auth();

if (orgId != null) {
console.log('Oh no, this page should only activate on the personal account!');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { auth } from '@clerk/nextjs/server';

export default function Page() {
const { userId, has } = auth();
export default async function Page() {
const { userId, has } = await auth();
if (!userId || !has({ permission: 'org:posts:manage' })) {
return <p>User is missing permissions</p>;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { auth } from '@clerk/nextjs/server';

export default function Page() {
auth().protect({ role: 'admin' });
export default async function Page() {
await auth.protect({ role: 'admin' });
return <p>User has access</p>;
}
9 changes: 7 additions & 2 deletions integration/templates/next-app-router/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ const csp = `default-src 'self';
`;

const isProtectedRoute = createRouteMatcher(['/protected(.*)', '/user(.*)', '/switcher(.*)']);
const isAdminRoute = createRouteMatcher(['/only-admin(.*)']);
const isCSPRoute = createRouteMatcher(['/csp']);

export default clerkMiddleware((auth, req) => {
export default clerkMiddleware(async (auth, req) => {
if (isProtectedRoute(req)) {
auth().protect();
await auth.protect();
}

if (isAdminRoute(req)) {
await auth.protect({ role: 'admin' });
}

if (isCSPRoute(req)) {
Expand Down
Loading

0 comments on commit d2a477f

Please sign in to comment.