Skip to content

Commit

Permalink
Merge branch 'main' into trpc11
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Feb 22, 2024
2 parents 2b254bd + 0418663 commit 2dd3166
Show file tree
Hide file tree
Showing 56 changed files with 2,468 additions and 321 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-points-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

chore: update drizzle-orm
5 changes: 5 additions & 0 deletions .changeset/dirty-birds-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: correct casing of “PlanetScale”
5 changes: 5 additions & 0 deletions .changeset/loud-pugs-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: fix password substitution in start-database scripts
5 changes: 5 additions & 0 deletions .changeset/nervous-oranges-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: generated comments in env file
5 changes: 5 additions & 0 deletions .changeset/sixty-rats-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

fix: use singleton pattern for client-side QueryClient to support `useSuspenseQuery` when there is no parent `<Suspense>`-element
5 changes: 5 additions & 0 deletions .changeset/smart-pumpkins-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

add missing `pg` dev dependency when using postgres drizzle option, required for `drizzle-studio`
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
build-t3-app:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
pl: ["matibox", "Infiplaya", "PiotrekPKP"],
pt: ["minsk-dev", "Sn0wye", "victoriaquasar", "MattFerreira18", "gilhrpenner"],
ru: ["AmadeusTwi", "ronanru", "JohnBakhmat"],
uk: ["pqoqubbw"],
"zh-hans": ["fernandoxu", "escwxyz"],
};
Expand Down
1 change: 1 addition & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The _"T3 Stack"_ is a web development stack made by [Theo](https://twitter.com/t
- [Tailwind CSS](https://tailwindcss.com)
- [TypeScript](https://typescriptlang.org)
- [Prisma](https://prisma.io)
- [Drizzle](https://orm.drizzle.team)
- [NextAuth.js](https://next-auth.js.org)

### So... what is `create-t3-app`? A template?
Expand Down
6 changes: 3 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"devDependencies": {
"@auth/drizzle-adapter": "^0.3.16",
"@auth/prisma-adapter": "^1.0.16",
"@planetscale/database": "^1.14.0",
"@planetscale/database": "^1.16.0",
"@prisma/adapter-planetscale": "^5.6.0",
"@prisma/client": "^5.6.0",
"@t3-oss/env-nextjs": "^0.7.1",
Expand All @@ -76,8 +76,8 @@
"@types/fs-extra": "^11.0.1",
"@types/gradient-string": "^1.1.2",
"@types/node": "^18.17.0",
"drizzle-kit": "^0.20.13",
"drizzle-orm": "^0.29.3",
"drizzle-kit": "^0.20.14",
"drizzle-orm": "^0.29.4",
"next": "^14.1.0",
"next-auth": "^4.24.5",
"prettier": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const runCli = async (): Promise<CliResults> => {
{ value: "sqlite", label: "SQLite" },
{ value: "mysql", label: "MySQL" },
{ value: "postgres", label: "PostgreSQL" },
{ value: "planetscale", label: "Planetscale" },
{ value: "planetscale", label: "PlanetScale" },
],
initialValue: "sqlite",
});
Expand Down
7 changes: 4 additions & 3 deletions cli/src/installers/dependencyVersionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ export const dependencyVersionMap = {
"@prisma/adapter-planetscale": "^5.6.0",

// Drizzle
"drizzle-orm": "^0.29.3",
"drizzle-kit": "^0.20.13",
"drizzle-orm": "^0.29.4",
"drizzle-kit": "^0.20.14",
mysql2: "^3.6.1",
"@planetscale/database": "^1.14.0",
"@planetscale/database": "^1.16.0",
postgres: "^3.4.3",
pg: "^8.11.3",
"@types/better-sqlite3": "^7.6.6",
"better-sqlite3": "^9.0.0",

Expand Down
1 change: 1 addition & 0 deletions cli/src/installers/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const drizzleInstaller: Installer = ({
const devPackages: AvailableDependencies[] = ["drizzle-kit"];
if (databaseProvider === "planetscale") devPackages.push("mysql2");
if (databaseProvider === "sqlite") devPackages.push("@types/better-sqlite3");
if (databaseProvider === "postgres") devPackages.push("pg");

addPackageDependency({
projectDir,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/installers/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ const getEnvContent = (
if (usingPrisma || usingDrizzle) {
if (databaseProvider === "planetscale") {
if (usingDrizzle) {
content += `Get the Database URL from the "prisma" dropdown selector in PlanetScale.
content += `# Get the Database URL from the "prisma" dropdown selector in PlanetScale.
# Change the query params at the end of the URL to "?ssl={"rejectUnauthorized":true}"
DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?ssl={"rejectUnauthorized":true}'`;
} else {
content = `Get the Database URL from the "prisma" dropdown selector in PlanetScale.
content = `# Get the Database URL from the "prisma" dropdown selector in PlanetScale.
DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?sslaccept=strict'`;
}
} else if (databaseProvider === "mysql") {
Expand Down
1 change: 1 addition & 0 deletions cli/template/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ If you are not familiar with the different technologies used in this project, pl
- [Next.js](https://nextjs.org)
- [NextAuth.js](https://next-auth.js.org)
- [Prisma](https://prisma.io)
- [Drizzle](https://orm.drizzle.team)
- [Tailwind CSS](https://tailwindcss.com)
- [tRPC](https://trpc.io)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@ import { drizzle } from "drizzle-orm/planetscale-serverless";
import { env } from "~/env";
import * as schema from "./schema";

export const db = drizzle(
new Client({
url: env.DATABASE_URL,
}).connection(),
{ schema }
);
export const db = drizzle(new Client({ url: env.DATABASE_URL }), { schema });
14 changes: 13 additions & 1 deletion cli/template/extras/src/trpc/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ import SuperJSON from "superjson";

import { type AppRouter } from "~/server/api/root";

const createQueryClient = () => new QueryClient();

let clientQueryClientSingleton: QueryClient | undefined = undefined;
const getQueryClient = () => {
if (typeof window === "undefined") {
// Server: always make a new query client
return createQueryClient();
}
// Browser: use singleton pattern to keep the same query client
return (clientQueryClientSingleton ??= createQueryClient());
};

export const api = createTRPCReact<AppRouter>();

export function TRPCReactProvider(props: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient());
const queryClient = getQueryClient();

const [trpcClient] = useState(() =>
api.createClient({
Expand Down
4 changes: 2 additions & 2 deletions cli/template/extras/start-database/mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 3. Open WSL - `wsl`
# 4. Run this script - `./start-database.sh`

# On Lunux and macOS you can run this script directly - `./start-database.sh`
# On Linux and macOS you can run this script directly - `./start-database.sh`

DB_CONTAINER_NAME="project1-mysql"

Expand Down Expand Up @@ -36,7 +36,7 @@ if [ "$DB_PASSWORD" == "password" ]; then
exit 1
fi
DB_PASSWORD=$(openssl rand -base64 12)
sed -i -e "s/:password@/:$DB_PASSWORD@/" .env
sed -i -e "s#:password@#:$DB_PASSWORD@#" .env
fi

docker run --name $DB_CONTAINER_NAME -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -e MYSQL_DATABASE=project1 -d -p 3306:3306 docker.io/mysql
Expand Down
4 changes: 2 additions & 2 deletions cli/template/extras/start-database/postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 3. Open WSL - `wsl`
# 4. Run this script - `./start-database.sh`

# On Lunux and macOS you can run this script directly - `./start-database.sh`
# On Linux and macOS you can run this script directly - `./start-database.sh`

DB_CONTAINER_NAME="project1-postgres"

Expand Down Expand Up @@ -36,7 +36,7 @@ if [ "$DB_PASSWORD" = "password" ]; then
exit 1
fi
DB_PASSWORD=$(openssl rand -base64 12)
sed -i -e "s/:password@/:$DB_PASSWORD@/" .env
sed -i -e "s#:password@#:$DB_PASSWORD@#" .env
fi

docker run --name $DB_CONTAINER_NAME -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_DB=project1 -d -p 5432:5432 docker.io/postgres
Expand Down
Loading

0 comments on commit 2dd3166

Please sign in to comment.