From 711f3b7d6274f446c331aa80b07102819f2f06ed Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 12:02:03 +0200 Subject: [PATCH 01/71] feat: add drizzle --- .github/workflows/e2e.yml | 7 +- .vscode/settings.json | 3 + cli/package.json | 2 + cli/src/cli/index.ts | 24 ++ cli/src/installers/dependencyVersionMap.ts | 6 + cli/src/installers/drizzle.ts | 48 ++++ cli/src/installers/envVars.ts | 22 +- cli/src/installers/index.ts | 6 + cli/src/installers/nextAuth.ts | 10 +- cli/src/installers/prisma.ts | 2 +- cli/src/installers/trpc.ts | 14 +- cli/template/extras/prisma/schema/base.prisma | 5 +- .../src/env/{with-prisma.mjs => with-db.mjs} | 4 +- .../api/routers/example/with-auth-drizzle.ts | 24 ++ .../api/routers/example/with-auth-prisma.ts | 2 +- .../api/routers/example/with-drizzle.ts | 15 ++ .../server/api/routers/example/with-prisma.ts | 2 +- .../{with-auth-prisma.ts => with-auth-db.ts} | 4 +- .../api/trpc/{with-prisma.ts => with-db.ts} | 4 +- .../extras/src/server/auth/with-drizzle.ts | 240 ++++++++++++++++++ .../extras/src/server/auth/with-prisma.ts | 4 +- .../src/server/{db.ts => db/db-prisma.ts} | 4 +- .../src/server/db/drizzle-schema-auth.ts | 69 +++++ .../src/server/db/drizzle-schema-base.ts | 20 ++ .../extras/src/server/db/index-drizzle.ts | 10 + pnpm-lock.yaml | 76 ++++++ 26 files changed, 600 insertions(+), 27 deletions(-) create mode 100644 cli/src/installers/drizzle.ts rename cli/template/extras/src/env/{with-prisma.mjs => with-db.mjs} (94%) create mode 100644 cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts create mode 100644 cli/template/extras/src/server/api/routers/example/with-drizzle.ts rename cli/template/extras/src/server/api/trpc/{with-auth-prisma.ts => with-auth-db.ts} (98%) rename cli/template/extras/src/server/api/trpc/{with-prisma.ts => with-db.ts} (98%) create mode 100644 cli/template/extras/src/server/auth/with-drizzle.ts rename cli/template/extras/src/server/{db.ts => db/db-prisma.ts} (77%) create mode 100644 cli/template/extras/src/server/db/drizzle-schema-auth.ts create mode 100644 cli/template/extras/src/server/db/drizzle-schema-base.ts create mode 100644 cli/template/extras/src/server/db/index-drizzle.ts diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index ad5e089cba..aaf1789734 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,8 +27,9 @@ jobs: tailwind: ["true", "false"] nextAuth: ["true", "false"] prisma: ["true", "false"] + drizzle: ["true", "false"] - name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}" + name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - uses: actions/checkout@v3 with: @@ -65,7 +66,7 @@ jobs: # has to be scaffolded outside the CLI project so that no lint/tsconfig are leaking # through. this way it ensures that it is the app's configs that are being used # FIXME: this is a bit hacky, would rather have --packages=trpc,tailwind,... but not sure how to setup the matrix for that - - run: cd cli && pnpm start ../../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }} --noGit --CI --trpc=${{ matrix.trpc }} --tailwind=${{ matrix.tailwind }} --nextAuth=${{ matrix.nextAuth }} --prisma=${{ matrix.prisma }} - - run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }} && pnpm build + - run: cd cli && pnpm start ../../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}} --noGit --CI --trpc=${{ matrix.trpc }} --tailwind=${{ matrix.tailwind }} --nextAuth=${{ matrix.nextAuth }} --prisma=${{ matrix.prisma }} --drizzle=${{ matrix.drizzle }} + - run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}} && pnpm build env: NEXTAUTH_SECRET: foo diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c13149fd3..3d7a747030 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,5 +24,8 @@ "mdx.experimentalLanguageServer": true, "[astro]": { "editor.defaultFormatter": "astro-build.astro-vscode" + }, + "[prisma]": { + "editor.defaultFormatter": "Prisma.prisma" } } diff --git a/cli/package.json b/cli/package.json index bb1e1ba21f..f4d851dfb4 100644 --- a/cli/package.json +++ b/cli/package.json @@ -52,6 +52,7 @@ "sort-package-json": "^2.4.1" }, "devDependencies": { + "@planetscale/database": "^1.7.0", "@prisma/client": "^4.14.0", "@t3-oss/env-nextjs": "^0.3.1", "@tanstack/react-query": "^4.29.7", @@ -63,6 +64,7 @@ "@types/gradient-string": "^1.1.2", "@types/inquirer": "^9.0.3", "@types/node": "^18.16.0", + "drizzle-orm": "^0.26.5", "next": "^13.4.1", "next-auth": "^4.22.1", "prettier": "^2.8.8", diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 73c8833879..c000330b61 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -25,6 +25,8 @@ interface CliFlags { /** @internal Used in CI. */ prisma: boolean; /** @internal Used in CI. */ + drizzle: boolean; + /** @internal Used in CI. */ nextAuth: boolean; } @@ -45,6 +47,7 @@ const defaultOptions: CliResults = { tailwind: false, trpc: false, prisma: false, + drizzle: false, nextAuth: false, importAlias: "~/", }, @@ -103,6 +106,12 @@ export const runCli = async () => { (value) => !!value && value !== "false", ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ + .option( + "--drizzle [boolean]", + "Experimental: Boolean value if we should install Drizzle. Must be used in conjunction with `--CI`.", + (value) => !!value && value !== "false", + ) + /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( "--trpc [boolean]", "Experimental: Boolean value if we should install tRPC. Must be used in conjunction with `--CI`.", @@ -152,7 +161,16 @@ export const runCli = async () => { if (cliResults.flags.trpc) cliResults.packages.push("trpc"); if (cliResults.flags.tailwind) cliResults.packages.push("tailwind"); if (cliResults.flags.prisma) cliResults.packages.push("prisma"); + if (cliResults.flags.drizzle) cliResults.packages.push("drizzle"); if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); + + if (cliResults.flags.prisma && cliResults.flags.drizzle) { + console.warn( + "Incompatible combination Prisma + Drizzle. Falling back to Prisma only.", + ); + cliResults.flags.drizzle = false; + cliResults.packages.splice(cliResults.packages.indexOf("drizzle"), 1); + } } // Explained below why this is in a try/catch block @@ -264,6 +282,12 @@ const promptPackages = async (): Promise => { name: pkgName, checked: false, })), + validate: (input: string[]) => { + if (input.includes("prisma") && input.includes("drizzle")) { + return "You cannot select both Prisma and Drizzle in the same app."; + } + return true; + }, }); return packages; diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 2bad6050fe..7682fb4cd2 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -11,6 +11,12 @@ export const dependencyVersionMap = { prisma: "^4.14.0", "@prisma/client": "^4.14.0", + // Drizzle + "drizzle-orm": "^0.26.3", + "drizzle-kit": "^0.18.1", + // REVIEW: Is it fine including pscale by default? + "@planetscale/database": "^1.7.0", + // TailwindCSS tailwindcss: "^3.3.0", autoprefixer: "^10.4.14", diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts new file mode 100644 index 0000000000..2e0a607e32 --- /dev/null +++ b/cli/src/installers/drizzle.ts @@ -0,0 +1,48 @@ +import fs from "fs-extra"; +import path from "path"; +import { type PackageJson } from "type-fest"; +import { PKG_ROOT } from "~/consts.js"; +import { type Installer } from "~/installers/index.js"; +import { addPackageDependency } from "~/utils/addPackageDependency.js"; + +export const drizzleInstaller: Installer = ({ projectDir, packages }) => { + addPackageDependency({ + projectDir, + dependencies: ["drizzle-kit"], + devMode: true, + }); + addPackageDependency({ + projectDir, + dependencies: ["drizzle-orm", "@planetscale/database"], + devMode: false, + }); + + const extrasDir = path.join(PKG_ROOT, "template/extras"); + + const schemaSrc = path.join( + extrasDir, + "src/server/db", + packages?.nextAuth.inUse + ? "drizzle-schema-auth.ts" + : "drizzle-schema-base.ts", + ); + const schemaDest = path.join(projectDir, "src/server/db/schema.ts"); + + const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); + const clientDest = path.join(projectDir, "src/server/db/index.ts"); + + // add db:push script to package.json + const packageJsonPath = path.join(projectDir, "package.json"); + + const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; + packageJsonContent.scripts = { + ...packageJsonContent.scripts, + "db:push": "drizzle-kit push:mysql", + }; + + fs.copySync(schemaSrc, schemaDest); + fs.copySync(clientSrc, clientDest); + fs.writeJSONSync(packageJsonPath, packageJsonContent, { + spaces: 2, + }); +}; diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index 6696470b77..d11c40f8d5 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -6,16 +6,17 @@ import { type Installer } from "~/installers/index.js"; export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; + const usingDrizzle = packages?.drizzle.inUse; - const envContent = getEnvContent(!!usingAuth, !!usingPrisma); + const envContent = getEnvContent(!!usingAuth, !!usingPrisma, !!usingDrizzle); const envFile = usingAuth && usingPrisma ? "with-auth-prisma.mjs" : usingAuth ? "with-auth.mjs" - : usingPrisma - ? "with-prisma.mjs" + : usingPrisma || usingDrizzle + ? "with-db.mjs" : ""; if (envFile !== "") { @@ -35,7 +36,11 @@ export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { fs.writeFileSync(envExampleDest, exampleEnvContent + envContent, "utf-8"); }; -const getEnvContent = (usingAuth: boolean, usingPrisma: boolean) => { +const getEnvContent = ( + usingAuth: boolean, + usingPrisma: boolean, + usingDrizzle: boolean, +) => { let content = ` # When adding additional environment variables, the schema in "/src/env.mjs" # should be updated accordingly. @@ -50,6 +55,15 @@ const getEnvContent = (usingAuth: boolean, usingPrisma: boolean) => { DATABASE_URL="file:./db.sqlite" `; + if (usingDrizzle) { + content += ` +# Drizzle +# 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}' +`; + } + if (usingAuth) content += ` # Next Auth diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 5f47d24b20..235ca5145f 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -1,3 +1,4 @@ +import { drizzleInstaller } from "./drizzle.js"; import { envVariablesInstaller } from "~/installers/envVars.js"; import { nextAuthInstaller } from "~/installers/nextAuth.js"; import { prismaInstaller } from "~/installers/prisma.js"; @@ -10,6 +11,7 @@ import { type PackageManager } from "~/utils/getUserPkgManager.js"; export const availablePackages = [ "nextAuth", "prisma", + "drizzle", "tailwind", "trpc", "envVariables", @@ -44,6 +46,10 @@ export const buildPkgInstallerMap = ( inUse: packages.includes("prisma"), installer: prismaInstaller, }, + drizzle: { + inUse: packages.includes("drizzle"), + installer: drizzleInstaller, + }, tailwind: { inUse: packages.includes("tailwind"), installer: tailwindInstaller, diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 628bbf272a..d7ba48ae63 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -7,8 +7,12 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; + const usingDrizzle = packages?.drizzle.inUse; + const deps: AvailableDependencies[] = ["next-auth"]; if (usingPrisma) deps.push("@next-auth/prisma-adapter"); + // This adapter is not yet available on npm so we have our own inhoused + // if (usingDrizzle) deps.push("@next-auth/drizzle-adapter"); addPackageDependency({ projectDir, @@ -25,7 +29,11 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const authConfigSrc = path.join( extrasDir, "src/server/auth", - usingPrisma ? "with-prisma.ts" : "base.ts", + usingPrisma + ? "with-prisma.ts" + : usingDrizzle + ? "with-drizzle.ts" + : "base.ts", ); const authConfigDest = path.join(projectDir, "src/server/auth.ts"); diff --git a/cli/src/installers/prisma.ts b/cli/src/installers/prisma.ts index fba0451aea..69b1984581 100644 --- a/cli/src/installers/prisma.ts +++ b/cli/src/installers/prisma.ts @@ -26,7 +26,7 @@ export const prismaInstaller: Installer = ({ projectDir, packages }) => { ); const schemaDest = path.join(projectDir, "prisma/schema.prisma"); - const clientSrc = path.join(extrasDir, "src/server/db.ts"); + const clientSrc = path.join(extrasDir, "src/server/db/db-prisma.ts"); const clientDest = path.join(projectDir, "src/server/db.ts"); // add postinstall script to package.json diff --git a/cli/src/installers/trpc.ts b/cli/src/installers/trpc.ts index 9901cdb8d9..2a77e2ecb7 100644 --- a/cli/src/installers/trpc.ts +++ b/cli/src/installers/trpc.ts @@ -20,6 +20,8 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; + const usingDrizzle = packages?.drizzle.inUse; + const usingDb = usingPrisma || usingDrizzle; const extrasDir = path.join(PKG_ROOT, "template/extras"); @@ -30,12 +32,12 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const utilsDest = path.join(projectDir, "src/utils/api.ts"); const trpcFile = - usingAuth && usingPrisma - ? "with-auth-prisma.ts" + usingAuth && usingDb + ? "with-auth-db.ts" : usingAuth ? "with-auth.ts" - : usingPrisma - ? "with-prisma.ts" + : usingDb + ? "with-db.ts" : "base.ts"; const trpcSrc = path.join(extrasDir, "src/server/api/trpc", trpcFile); const trpcDest = path.join(projectDir, "src/server/api/trpc.ts"); @@ -46,10 +48,14 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const exampleRouterFile = usingAuth && usingPrisma ? "with-auth-prisma.ts" + : usingAuth && usingDrizzle + ? "with-auth-drizzle.ts" : usingAuth ? "with-auth.ts" : usingPrisma ? "with-prisma.ts" + : usingDrizzle + ? "with-drizzle.ts" : "base.ts"; const exampleRouterSrc = path.join( diff --git a/cli/template/extras/prisma/schema/base.prisma b/cli/template/extras/prisma/schema/base.prisma index a2974071a0..4b6dfbfb11 100644 --- a/cli/template/extras/prisma/schema/base.prisma +++ b/cli/template/extras/prisma/schema/base.prisma @@ -2,7 +2,7 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" previewFeatures = ["jsonProtocol"] } @@ -12,7 +12,8 @@ datasource db { } model Example { - id String @id @default(cuid()) + id Int @id @default(autoincrement()) + number Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/cli/template/extras/src/env/with-prisma.mjs b/cli/template/extras/src/env/with-db.mjs similarity index 94% rename from cli/template/extras/src/env/with-prisma.mjs rename to cli/template/extras/src/env/with-db.mjs index 67fa767443..3bc39f515e 100644 --- a/cli/template/extras/src/env/with-prisma.mjs +++ b/cli/template/extras/src/env/with-db.mjs @@ -30,8 +30,8 @@ export const env = createEnv({ // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, }, /** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. - * This is especially useful for Docker builds. + * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially + * useful for Docker builds. */ skipValidation: !!process.env.SKIP_ENV_VALIDATION, }); diff --git a/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts b/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts new file mode 100644 index 0000000000..42e3411c55 --- /dev/null +++ b/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts @@ -0,0 +1,24 @@ +import { z } from "zod"; +import { + createTRPCRouter, + publicProcedure, + protectedProcedure, +} from "~/server/api/trpc"; + +export const exampleRouter = createTRPCRouter({ + hello: publicProcedure + .input(z.object({ text: z.string() })) + .query(({ input }) => { + return { + greeting: `Hello ${input.text}`, + }; + }), + + getAll: publicProcedure.query(({ ctx }) => { + return ctx.db.query.example.findMany(); + }), + + getSecretMessage: protectedProcedure.query(() => { + return "you can now see this secret message!"; + }), +}); diff --git a/cli/template/extras/src/server/api/routers/example/with-auth-prisma.ts b/cli/template/extras/src/server/api/routers/example/with-auth-prisma.ts index fbb066a5e8..df8ecbdebd 100644 --- a/cli/template/extras/src/server/api/routers/example/with-auth-prisma.ts +++ b/cli/template/extras/src/server/api/routers/example/with-auth-prisma.ts @@ -15,7 +15,7 @@ export const exampleRouter = createTRPCRouter({ }), getAll: publicProcedure.query(({ ctx }) => { - return ctx.prisma.example.findMany(); + return ctx.db.example.findMany(); }), getSecretMessage: protectedProcedure.query(() => { diff --git a/cli/template/extras/src/server/api/routers/example/with-drizzle.ts b/cli/template/extras/src/server/api/routers/example/with-drizzle.ts new file mode 100644 index 0000000000..7e58cd36da --- /dev/null +++ b/cli/template/extras/src/server/api/routers/example/with-drizzle.ts @@ -0,0 +1,15 @@ +import { z } from "zod"; +import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; + +export const exampleRouter = createTRPCRouter({ + hello: publicProcedure + .input(z.object({ text: z.string() })) + .query(({ input }) => { + return { + greeting: `Hello ${input.text}`, + }; + }), + getAll: publicProcedure.query(({ ctx }) => { + return ctx.db.query.example.findMany(); + }), +}); diff --git a/cli/template/extras/src/server/api/routers/example/with-prisma.ts b/cli/template/extras/src/server/api/routers/example/with-prisma.ts index 50c47c671e..29a7592ce0 100644 --- a/cli/template/extras/src/server/api/routers/example/with-prisma.ts +++ b/cli/template/extras/src/server/api/routers/example/with-prisma.ts @@ -10,6 +10,6 @@ export const exampleRouter = createTRPCRouter({ }; }), getAll: publicProcedure.query(({ ctx }) => { - return ctx.prisma.example.findMany(); + return ctx.db.example.findMany(); }), }); diff --git a/cli/template/extras/src/server/api/trpc/with-auth-prisma.ts b/cli/template/extras/src/server/api/trpc/with-auth-db.ts similarity index 98% rename from cli/template/extras/src/server/api/trpc/with-auth-prisma.ts rename to cli/template/extras/src/server/api/trpc/with-auth-db.ts index c2491f0a88..0b44b29393 100644 --- a/cli/template/extras/src/server/api/trpc/with-auth-prisma.ts +++ b/cli/template/extras/src/server/api/trpc/with-auth-db.ts @@ -13,7 +13,7 @@ import { type Session } from "next-auth"; import superjson from "superjson"; import { ZodError } from "zod"; import { getServerAuthSession } from "~/server/auth"; -import { prisma } from "~/server/db"; +import { db } from "~/server/db"; /** * 1. CONTEXT @@ -40,7 +40,7 @@ type CreateContextOptions = { const createInnerTRPCContext = (opts: CreateContextOptions) => { return { session: opts.session, - prisma, + db, }; }; diff --git a/cli/template/extras/src/server/api/trpc/with-prisma.ts b/cli/template/extras/src/server/api/trpc/with-db.ts similarity index 98% rename from cli/template/extras/src/server/api/trpc/with-prisma.ts rename to cli/template/extras/src/server/api/trpc/with-db.ts index ff19e2b821..d9b02e8d3c 100644 --- a/cli/template/extras/src/server/api/trpc/with-prisma.ts +++ b/cli/template/extras/src/server/api/trpc/with-db.ts @@ -10,7 +10,7 @@ import { initTRPC } from "@trpc/server"; import { type CreateNextContextOptions } from "@trpc/server/adapters/next"; import superjson from "superjson"; import { ZodError } from "zod"; -import { prisma } from "~/server/db"; +import { db } from "~/server/db"; /** * 1. CONTEXT @@ -34,7 +34,7 @@ type CreateContextOptions = Record; */ const createInnerTRPCContext = (_opts: CreateContextOptions) => { return { - prisma, + db, }; }; diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts new file mode 100644 index 0000000000..e2ff11d436 --- /dev/null +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -0,0 +1,240 @@ +import { and, eq } from "drizzle-orm"; +import { type GetServerSidePropsContext } from "next"; +import { + getServerSession, + type NextAuthOptions, + type DefaultSession, +} from "next-auth"; +import { type Adapter } from "next-auth/adapters"; +import DiscordProvider from "next-auth/providers/discord"; +import { env } from "~/env.mjs"; +import { db } from "~/server/db"; +import * as schema from "~/server/db/schema"; + +/** + * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` + * object and keep type safety. + * + * @see https://next-auth.js.org/getting-started/typescript#module-augmentation + */ +declare module "next-auth" { + interface Session extends DefaultSession { + user: { + id: string; + // ...other properties + // role: UserRole; + } & DefaultSession["user"]; + } + + // interface User { + // // ...other properties + // // role: UserRole; + // } +} + +/** + * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. + * + * @see https://next-auth.js.org/configuration/options + */ +export const authOptions: NextAuthOptions = { + callbacks: { + session: ({ session, user }) => ({ + ...session, + user: { + ...session.user, + id: user.id, + }, + }), + }, + adapter: DrizzleAdapter(), + providers: [ + DiscordProvider({ + clientId: env.DISCORD_CLIENT_ID, + clientSecret: env.DISCORD_CLIENT_SECRET, + }), + /** + * ...add more providers here. + * + * Most other providers require a bit more work than the Discord provider. For example, the + * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account + * model. Refer to the NextAuth.js docs for the provider you want to use. Example: + * + * @see https://next-auth.js.org/providers/github + */ + ], +}; + +/** + * Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file. + * + * @see https://next-auth.js.org/configuration/nextjs + */ +export const getServerAuthSession = (ctx: { + req: GetServerSidePropsContext["req"]; + res: GetServerSidePropsContext["res"]; +}) => { + return getServerSession(ctx.req, ctx.res, authOptions); +}; + +/** + * Adapter for Drizzle ORM. This is not yet available in NextAuth directly, so we inhouse our own. + * When the official one is out, we will switch to that. + * + * @see + * https://github.com/nextauthjs/next-auth/pull/7165/files#diff-142e7d6584eed63a73316fbc041fb93a0564a1cbb0da71200b92628ca66024b5 + */ + +export function DrizzleAdapter(): Adapter { + const { users, sessions, accounts, verificationTokens } = schema; + return { + createUser: async (data) => { + const id = crypto.randomUUID(); + + await db.insert(users).values({ ...data, id }); + + const user = await db + .select() + .from(users) + .where(eq(users.id, id)) + .then((res) => res[0]); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return user!; + }, + getUser: async (data) => { + const user = await db.select().from(users).where(eq(users.id, data)); + return user[0] ?? null; + }, + getUserByEmail: async (data) => { + const user = await db.select().from(users).where(eq(users.email, data)); + return user[0] ?? null; + }, + createSession: async (data) => { + await db.insert(sessions).values(data); + + const session = await db + .select() + .from(sessions) + .where(eq(sessions.sessionToken, data.sessionToken)); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return session[0]!; + }, + getSessionAndUser: async (data) => { + const sessionAndUser = await db + .select({ + session: sessions, + user: users, + }) + .from(sessions) + .where(eq(sessions.sessionToken, data)) + .innerJoin(users, eq(users.id, sessions.userId)); + + return sessionAndUser[0] ?? null; + }, + updateUser: async (data) => { + if (!data.id) { + throw new Error("No user id."); + } + + await db.update(users).set(data).where(eq(users.id, data.id)); + + const user = await db.select().from(users).where(eq(users.id, data.id)); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return user[0]!; + }, + updateSession: async (data) => { + await db + .update(sessions) + .set(data) + .where(eq(sessions.sessionToken, data.sessionToken)); + + return db + .select() + .from(sessions) + .where(eq(sessions.sessionToken, data.sessionToken)) + .then((res) => res[0]); + }, + linkAccount: async (rawAccount) => { + await db + .insert(accounts) + .values(rawAccount) + .then((res) => res.rows[0]); + }, + getUserByAccount: async (account) => { + const dbAccount = await db + .select() + .from(accounts) + .where( + and( + eq(accounts.providerAccountId, account.providerAccountId), + eq(accounts.provider, account.provider), + ), + ) + .leftJoin(users, eq(accounts.userId, users.id)) + .then((res) => res[0]); + + return dbAccount?.users ?? null; + }, + deleteSession: async (sessionToken) => { + await db.delete(sessions).where(eq(sessions.sessionToken, sessionToken)); + }, + createVerificationToken: async (token) => { + await db.insert(verificationTokens).values(token); + + return db + .select() + .from(verificationTokens) + .where(eq(verificationTokens.identifier, token.identifier)) + .then((res) => res[0]); + }, + useVerificationToken: async (token) => { + try { + const deletedToken = + (await db + .select() + .from(verificationTokens) + .where( + and( + eq(verificationTokens.identifier, token.identifier), + eq(verificationTokens.token, token.token), + ), + ) + .then((res) => res[0])) ?? null; + + await db + .delete(verificationTokens) + .where( + and( + eq(verificationTokens.identifier, token.identifier), + eq(verificationTokens.token, token.token), + ), + ); + + return deletedToken; + } catch (err) { + throw new Error("No verification token found."); + } + }, + deleteUser: async (id) => { + await Promise.all([ + db.delete(users).where(eq(users.id, id)), + db.delete(sessions).where(eq(sessions.userId, id)), + db.delete(accounts).where(eq(accounts.userId, id)), + ]); + + return null; + }, + unlinkAccount: async (account) => { + await db + .delete(accounts) + .where( + and( + eq(accounts.providerAccountId, account.providerAccountId), + eq(accounts.provider, account.provider), + ), + ); + + return undefined; + }, + }; +} diff --git a/cli/template/extras/src/server/auth/with-prisma.ts b/cli/template/extras/src/server/auth/with-prisma.ts index e3f544447d..57b3b0b03b 100644 --- a/cli/template/extras/src/server/auth/with-prisma.ts +++ b/cli/template/extras/src/server/auth/with-prisma.ts @@ -7,7 +7,7 @@ import { } from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env.mjs"; -import { prisma } from "~/server/db"; +import { db } from "~/server/db"; /** * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` @@ -45,7 +45,7 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: PrismaAdapter(prisma), + adapter: PrismaAdapter(db), providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, diff --git a/cli/template/extras/src/server/db.ts b/cli/template/extras/src/server/db/db-prisma.ts similarity index 77% rename from cli/template/extras/src/server/db.ts rename to cli/template/extras/src/server/db/db-prisma.ts index 87ece8b701..8982b1cfa5 100644 --- a/cli/template/extras/src/server/db.ts +++ b/cli/template/extras/src/server/db/db-prisma.ts @@ -5,11 +5,11 @@ const globalForPrisma = globalThis as unknown as { prisma: PrismaClient | undefined; }; -export const prisma = +export const db = globalForPrisma.prisma ?? new PrismaClient({ log: env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"], }); -if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma; +if (env.NODE_ENV !== "production") globalForPrisma.prisma = db; diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts new file mode 100644 index 0000000000..eb1ed6c76b --- /dev/null +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -0,0 +1,69 @@ +import { + int, + timestamp, + mysqlTable, + varchar, + primaryKey, + serial, + uniqueIndex, +} from "drizzle-orm/mysql-core"; +import { type AdapterAccount } from "next-auth/adapters"; + +export const example = mysqlTable( + "example", + { + id: serial("id").primaryKey(), + number: varchar("number", { length: 256 }), + }, + (example) => ({ + numberIndex: uniqueIndex("number_idx").on(example.number), + }), +); + +export const users = mysqlTable("users", { + id: varchar("id", { length: 255 }).notNull().primaryKey(), + name: varchar("name", { length: 255 }), + email: varchar("email", { length: 255 }).notNull(), + emailVerified: timestamp("emailVerified", { mode: "date" }), + image: varchar("image", { length: 255 }), +}); + +export const accounts = mysqlTable( + "accounts", + { + userId: varchar("userId", { length: 255 }).notNull(), + type: varchar("type", { length: 255 }) + .$type() + .notNull(), + provider: varchar("provider", { length: 255 }).notNull(), + providerAccountId: varchar("providerAccountId", { length: 255 }).notNull(), + refresh_token: varchar("refresh_token", { length: 255 }), + access_token: varchar("access_token", { length: 255 }), + expires_at: int("expires_at"), + token_type: varchar("token_type", { length: 255 }), + scope: varchar("scope", { length: 255 }), + id_token: varchar("id_token", { length: 255 }), + session_state: varchar("session_state", { length: 255 }), + }, + (account) => ({ + compoundKey: primaryKey(account.provider, account.providerAccountId), + }), +); + +export const sessions = mysqlTable("sessions", { + sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(), + userId: varchar("userId", { length: 255 }).notNull(), + expires: timestamp("expires", { mode: "date" }).notNull(), +}); + +export const verificationTokens = mysqlTable( + "verificationToken", + { + identifier: varchar("identifier", { length: 255 }).notNull(), + token: varchar("token", { length: 255 }).notNull(), + expires: timestamp("expires", { mode: "date" }).notNull(), + }, + (vt) => ({ + compoundKey: primaryKey(vt.identifier, vt.token), + }), +); diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts new file mode 100644 index 0000000000..6e32686259 --- /dev/null +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -0,0 +1,20 @@ +// Example model schema from the Drizzle docs +// https://orm.drizzle.team/docs/sql-schema-declaration + +import { + mysqlTable, + serial, + uniqueIndex, + varchar, +} from "drizzle-orm/mysql-core"; + +export const example = mysqlTable( + "example", + { + id: serial("id").primaryKey(), + number: varchar("number", { length: 256 }), + }, + (example) => ({ + numberIndex: uniqueIndex("number_idx").on(example.number), + }), +); diff --git a/cli/template/extras/src/server/db/index-drizzle.ts b/cli/template/extras/src/server/db/index-drizzle.ts new file mode 100644 index 0000000000..1bb23c8e81 --- /dev/null +++ b/cli/template/extras/src/server/db/index-drizzle.ts @@ -0,0 +1,10 @@ +import * as schema from "./schema"; +import { connect } from "@planetscale/database"; +import { drizzle } from "drizzle-orm/planetscale-serverless"; + +// create the connection +const connection = connect({ + url: process.env["DATABASE_URL"], +}); + +export const db = drizzle(connection, { schema }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 373a688c91..afa6949d99 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,6 +95,9 @@ importers: specifier: ^2.4.1 version: 2.4.1 devDependencies: + '@planetscale/database': + specifier: ^1.7.0 + version: 1.7.0 '@prisma/client': specifier: ^4.14.0 version: 4.14.0(prisma@4.14.0) @@ -128,6 +131,9 @@ importers: '@types/node': specifier: ^18.16.0 version: 18.16.1 + drizzle-orm: + specifier: ^0.26.5 + version: 0.26.5(@planetscale/database@1.7.0) next: specifier: ^13.4.1 version: 13.4.1(@babel/core@7.21.3)(react-dom@18.2.0)(react@18.2.0) @@ -1867,6 +1873,11 @@ packages: tiny-glob: 0.2.9 tslib: 2.5.0 + /@planetscale/database@1.7.0: + resolution: {integrity: sha512-lWR6biXChUyQnxsT4RT1CIeR3ZJvwTQXiQ+158MnY3VjLwjHEGakDzdH9kwUGPk6CHvu6UeqRXp1DgUOVHJFTw==} + engines: {node: '>=16'} + dev: true + /@prisma/client@4.14.0(prisma@4.14.0): resolution: {integrity: sha512-MK/XaA2sFdfaOa7I9MjNKz6dxeIEdeZlnpNRoF2w3JuRLlFJLkpp6cD3yaqw2nUUhbrn3Iqe3ZpVV+VuGGil7Q==} engines: {node: '>=14.17'} @@ -4056,6 +4067,71 @@ packages: engines: {node: '>=10'} dev: false + /drizzle-orm@0.26.5(@planetscale/database@1.7.0): + resolution: {integrity: sha512-ajjbOIoXqldWoWBn0RbVQCCT732R4Ad+gUjUrlmMpzWYwgnbG/qqPy84NhHntQ/MR//z3xfvT1Z2fD8uCAPX3g==} + peerDependencies: + '@aws-sdk/client-rds-data': '>=3' + '@cloudflare/workers-types': '>=3' + '@libsql/client': '*' + '@neondatabase/serverless': '>=0.1' + '@opentelemetry/api': ^1.4.1 + '@planetscale/database': '>=1' + '@types/better-sqlite3': '*' + '@types/pg': '*' + '@types/sql.js': '*' + '@vercel/postgres': '*' + better-sqlite3: '>=7' + bun-types: '*' + knex: '*' + kysely: '*' + mysql2: '>=2' + pg: '>=8' + postgres: '>=3' + sql.js: '>=1' + sqlite3: '>=5' + peerDependenciesMeta: + '@aws-sdk/client-rds-data': + optional: true + '@cloudflare/workers-types': + optional: true + '@libsql/client': + optional: true + '@neondatabase/serverless': + optional: true + '@opentelemetry/api': + optional: true + '@planetscale/database': + optional: true + '@types/better-sqlite3': + optional: true + '@types/pg': + optional: true + '@types/sql.js': + optional: true + '@vercel/postgres': + optional: true + better-sqlite3: + optional: true + bun-types: + optional: true + knex: + optional: true + kysely: + optional: true + mysql2: + optional: true + pg: + optional: true + postgres: + optional: true + sql.js: + optional: true + sqlite3: + optional: true + dependencies: + '@planetscale/database': 1.7.0 + dev: true + /dset@3.1.2: resolution: {integrity: sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==} engines: {node: '>=4'} From 365f711c4424314ecf99612af8cc3b00e67b40d6 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 17:44:31 +0200 Subject: [PATCH 02/71] log next steps --- cli/src/helpers/logNextSteps.ts | 9 ++++++--- cli/src/installers/prisma.ts | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index d1bdcef44c..418a6deccb 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -23,10 +23,13 @@ export const logNextSteps = ({ } if (packages?.prisma.inUse) { - logger.info( - ` ${pkgManager === "npm" ? "npx" : pkgManager} prisma db push`, - ); + logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} db:push`); } logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} dev`); + + logger.warn( + `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, + `\nNote: We use the PlanetScale driver. If you want to use a different driver, you'll need to change it yourself.`, + ); }; diff --git a/cli/src/installers/prisma.ts b/cli/src/installers/prisma.ts index 69b1984581..8387a3d5b4 100644 --- a/cli/src/installers/prisma.ts +++ b/cli/src/installers/prisma.ts @@ -29,13 +29,14 @@ export const prismaInstaller: Installer = ({ projectDir, packages }) => { const clientSrc = path.join(extrasDir, "src/server/db/db-prisma.ts"); const clientDest = path.join(projectDir, "src/server/db.ts"); - // add postinstall script to package.json + // add postinstall and push script to package.json const packageJsonPath = path.join(projectDir, "package.json"); const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; packageJsonContent.scripts = { ...packageJsonContent.scripts, postinstall: "prisma generate", + "db:push": "prisma db push", }; fs.copySync(schemaSrc, schemaDest); From 54898e12c1370b2578d744250e1ee0717dc5293d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 4 Jun 2023 18:40:09 +0200 Subject: [PATCH 03/71] Create fast-teachers-explain.md --- .changeset/fast-teachers-explain.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .changeset/fast-teachers-explain.md diff --git a/.changeset/fast-teachers-explain.md b/.changeset/fast-teachers-explain.md new file mode 100644 index 0000000000..8c34f584a2 --- /dev/null +++ b/.changeset/fast-teachers-explain.md @@ -0,0 +1,22 @@ +--- +"create-t3-app": patch +--- + +feat: add drizzle + +This release adds a new option to use [`drizzle-orm`](https://orm.drizzle.team/) as an alternative to Prisma. + +To make the different ORM options as similar as possible, some minor changes has also been made to the Prisma installer: + +- a new script `db:push` has been added and is included in both ORM options. +- the prisma client has been renamed to `db` in the trpc context - you now access your database client like + ```ts + examples: publicProcedure.query((opts) => { + // prisma + opts.ctx.db.example.findMany() + // drizzle + opts.ctx.cb.query.example.findMany() + }), + ``` + +You cannot choose the two options in the same app. From 21a7062c1a45b0c89b594dcdafe590991ee674e0 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 20:42:18 +0200 Subject: [PATCH 04/71] add config file for push --- cli/src/installers/dependencyVersionMap.ts | 1 + cli/src/installers/drizzle.ts | 6 +++++- cli/template/extras/config/drizzle.config.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 cli/template/extras/config/drizzle.config.ts diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 7682fb4cd2..bd5c503797 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -14,6 +14,7 @@ export const dependencyVersionMap = { // Drizzle "drizzle-orm": "^0.26.3", "drizzle-kit": "^0.18.1", + dotenv: "^16.1.4", // REVIEW: Is it fine including pscale by default? "@planetscale/database": "^1.7.0", diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 2e0a607e32..0c2a3d6249 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -8,7 +8,7 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const drizzleInstaller: Installer = ({ projectDir, packages }) => { addPackageDependency({ projectDir, - dependencies: ["drizzle-kit"], + dependencies: ["drizzle-kit", "dotenv"], devMode: true, }); addPackageDependency({ @@ -19,6 +19,9 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { const extrasDir = path.join(PKG_ROOT, "template/extras"); + const configFile = path.join(extrasDir, "config/drizzle.config.ts"); + const configDest = path.join(projectDir, "drizzle.config.ts"); + const schemaSrc = path.join( extrasDir, "src/server/db", @@ -40,6 +43,7 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { "db:push": "drizzle-kit push:mysql", }; + fs.copySync(configFile, configDest); fs.copySync(schemaSrc, schemaDest); fs.copySync(clientSrc, clientDest); fs.writeJSONSync(packageJsonPath, packageJsonContent, { diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts new file mode 100644 index 0000000000..834b1fce6d --- /dev/null +++ b/cli/template/extras/config/drizzle.config.ts @@ -0,0 +1,8 @@ +import type { Config } from "drizzle-kit"; +import * as dotenv from "dotenv"; +dotenv.config(); + +export default { + schema: "./src/server/db/schema.ts", + connectionString: process.env.DATABASE_URL, +} satisfies Config; From 9eb1af142e9604271dfbb4948b948dfcf288ca3b Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 4 Jun 2023 20:44:57 +0200 Subject: [PATCH 05/71] Update cli/template/extras/config/drizzle.config.ts --- cli/template/extras/config/drizzle.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index 834b1fce6d..f23a3774fa 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,4 +1,4 @@ -import type { Config } from "drizzle-kit"; +import { type Config } from "drizzle-kit"; import * as dotenv from "dotenv"; dotenv.config(); From eb6040c6c91298be060b09d9187b368de147ac06 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 21:05:14 +0200 Subject: [PATCH 06/71] ? --- cli/template/extras/config/drizzle.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index f23a3774fa..65702f45e7 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,5 +1,6 @@ import { type Config } from "drizzle-kit"; import * as dotenv from "dotenv"; + dotenv.config(); export default { From 52fd092ea72fc98a0f063e5a3c3e75a72f847ea7 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 21:35:11 +0200 Subject: [PATCH 07/71] fix log --- cli/src/helpers/logNextSteps.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index 418a6deccb..b42e727189 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -28,8 +28,10 @@ export const logNextSteps = ({ logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} dev`); - logger.warn( - `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, - `\nNote: We use the PlanetScale driver. If you want to use a different driver, you'll need to change it yourself.`, - ); + if (packages?.drizzle.inUse) { + logger.warn( + `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, + `\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.`, + ); + } }; From 8b3c3346fa473f7b72cdbabd23d88125cf0ef60c Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 4 Jun 2023 23:23:52 +0200 Subject: [PATCH 08/71] what's wrong pretier --- cli/template/extras/config/drizzle.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index 65702f45e7..4226a1fd38 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,5 +1,5 @@ -import { type Config } from "drizzle-kit"; import * as dotenv from "dotenv"; +import { type Config } from "drizzle-kit"; dotenv.config(); From 3fb205eb41474c0e4dd8abc5348a0df198786342 Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Tue, 27 Jun 2023 21:02:32 +0200 Subject: [PATCH 09/71] rename number to name because its a varchar field --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 4 ++-- cli/template/extras/src/server/db/drizzle-schema-base.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index eb1ed6c76b..b964c4f2bc 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -13,10 +13,10 @@ export const example = mysqlTable( "example", { id: serial("id").primaryKey(), - number: varchar("number", { length: 256 }), + name: varchar("name", { length: 256 }), }, (example) => ({ - numberIndex: uniqueIndex("number_idx").on(example.number), + nameIndex: uniqueIndex("name_idx").on(example.name), }), ); diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index 6e32686259..82f8281a5f 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -12,9 +12,9 @@ export const example = mysqlTable( "example", { id: serial("id").primaryKey(), - number: varchar("number", { length: 256 }), + name: varchar("name", { length: 256 }), }, (example) => ({ - numberIndex: uniqueIndex("number_idx").on(example.number), + nameIndex: uniqueIndex("name_idx").on(example.name), }), ); From 1dd1db8ac6dfd2eab9f952ce67e7c77e7ae3bd76 Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Tue, 27 Jun 2023 21:34:22 +0200 Subject: [PATCH 10/71] add next step --- cli/src/helpers/logNextSteps.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index b42e727189..47ed848183 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -26,6 +26,12 @@ export const logNextSteps = ({ logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} db:push`); } + if (packages?.drizzle.inUse) { + logger.info( + ` ${pkgManager === "npm" ? "npx" : pkgManager} drizzle-kit push:mysql`, + ); + } + logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} dev`); if (packages?.drizzle.inUse) { From d684c7e2ca9c9d92bd6d5adb0ad2f6dd6152ede9 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 2 Jul 2023 10:46:24 +0200 Subject: [PATCH 11/71] fix schemas --- .changeset/fast-teachers-explain.md | 2 +- cli/template/extras/prisma/schema/base.prisma | 4 ++- .../extras/prisma/schema/with-auth.prisma | 7 ++++-- .../src/server/db/drizzle-schema-auth.ts | 25 ++++++++++++++++++- .../src/server/db/drizzle-schema-base.ts | 13 +++++++++- .../extras/src/server/db/index-drizzle.ts | 3 ++- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/.changeset/fast-teachers-explain.md b/.changeset/fast-teachers-explain.md index 8c34f584a2..b333cd99f9 100644 --- a/.changeset/fast-teachers-explain.md +++ b/.changeset/fast-teachers-explain.md @@ -15,7 +15,7 @@ To make the different ORM options as similar as possible, some minor changes has // prisma opts.ctx.db.example.findMany() // drizzle - opts.ctx.cb.query.example.findMany() + opts.ctx.db.query.example.findMany() }), ``` diff --git a/cli/template/extras/prisma/schema/base.prisma b/cli/template/extras/prisma/schema/base.prisma index 4b6dfbfb11..6040d25bd6 100644 --- a/cli/template/extras/prisma/schema/base.prisma +++ b/cli/template/extras/prisma/schema/base.prisma @@ -13,7 +13,9 @@ datasource db { model Example { id Int @id @default(autoincrement()) - number Int + name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + + @@index([name]) } diff --git a/cli/template/extras/prisma/schema/with-auth.prisma b/cli/template/extras/prisma/schema/with-auth.prisma index a352ad5968..238b2f88f0 100644 --- a/cli/template/extras/prisma/schema/with-auth.prisma +++ b/cli/template/extras/prisma/schema/with-auth.prisma @@ -2,7 +2,7 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" previewFeatures = ["jsonProtocol"] } @@ -16,9 +16,12 @@ datasource db { } model Example { - id String @id @default(cuid()) + id Int @id @default(autoincrement()) + name String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + + @@index([name]) } // Necessary for Next auth diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index b964c4f2bc..b4adb36399 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -1,7 +1,8 @@ +import { relations } from "drizzle-orm"; import { int, timestamp, - mysqlTable, + mysqlTableCreator, varchar, primaryKey, serial, @@ -9,11 +10,21 @@ import { } from "drizzle-orm/mysql-core"; import { type AdapterAccount } from "next-auth/adapters"; +/** + * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same + * database instance for multiple projects. + * + * @see https://orm.drizzle.team/docs/goodies#multi-project-schema + */ +const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); + export const example = mysqlTable( "example", { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ nameIndex: uniqueIndex("name_idx").on(example.name), @@ -28,6 +39,10 @@ export const users = mysqlTable("users", { image: varchar("image", { length: 255 }), }); +export const usersRelations = relations(users, ({ many }) => ({ + accounts: many(accounts), +})); + export const accounts = mysqlTable( "accounts", { @@ -50,12 +65,20 @@ export const accounts = mysqlTable( }), ); +export const accountsRelations = relations(accounts, ({ one }) => ({ + user: one(users, { fields: [accounts.userId], references: [users.id] }), +})); + export const sessions = mysqlTable("sessions", { sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(), userId: varchar("userId", { length: 255 }).notNull(), expires: timestamp("expires", { mode: "date" }).notNull(), }); +export const sessionsRelations = relations(sessions, ({ one }) => ({ + user: one(users, { fields: [sessions.userId], references: [users.id] }), +})); + export const verificationTokens = mysqlTable( "verificationToken", { diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index 82f8281a5f..dd37019e26 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -2,17 +2,28 @@ // https://orm.drizzle.team/docs/sql-schema-declaration import { - mysqlTable, + mysqlTableCreator, serial, + timestamp, uniqueIndex, varchar, } from "drizzle-orm/mysql-core"; +/** + * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same + * database instance for multiple projects. + * + * @see https://orm.drizzle.team/docs/goodies#multi-project-schema + */ +const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); + export const example = mysqlTable( "example", { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), + createdAt: timestamp("created_at").defaultNow().notNull(), + updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ nameIndex: uniqueIndex("name_idx").on(example.name), diff --git a/cli/template/extras/src/server/db/index-drizzle.ts b/cli/template/extras/src/server/db/index-drizzle.ts index 1bb23c8e81..1d684e71e3 100644 --- a/cli/template/extras/src/server/db/index-drizzle.ts +++ b/cli/template/extras/src/server/db/index-drizzle.ts @@ -1,10 +1,11 @@ import * as schema from "./schema"; import { connect } from "@planetscale/database"; import { drizzle } from "drizzle-orm/planetscale-serverless"; +import { env } from "~/env.mjs"; // create the connection const connection = connect({ - url: process.env["DATABASE_URL"], + url: env.DATABASE_URL, }); export const db = drizzle(connection, { schema }); From f37b9de04f780f4a3f79e74f57a9efa5cf1cff7a Mon Sep 17 00:00:00 2001 From: Midas <108333567+xiften@users.noreply.github.com> Date: Sun, 30 Jul 2023 23:51:13 +0530 Subject: [PATCH 12/71] changed varchar to text on drizzle nextauth to prevent auth errors (#1486) --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index b4adb36399..f049ef3ac3 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -7,6 +7,7 @@ import { primaryKey, serial, uniqueIndex, + text, } from "drizzle-orm/mysql-core"; import { type AdapterAccount } from "next-auth/adapters"; @@ -52,12 +53,12 @@ export const accounts = mysqlTable( .notNull(), provider: varchar("provider", { length: 255 }).notNull(), providerAccountId: varchar("providerAccountId", { length: 255 }).notNull(), - refresh_token: varchar("refresh_token", { length: 255 }), - access_token: varchar("access_token", { length: 255 }), + refresh_token: text("refresh_token"), + access_token: text("access_token"), expires_at: int("expires_at"), token_type: varchar("token_type", { length: 255 }), scope: varchar("scope", { length: 255 }), - id_token: varchar("id_token", { length: 255 }), + id_token: text("id_token"), session_state: varchar("session_state", { length: 255 }), }, (account) => ({ From 6352f520fd6023488f0b26066d548c33980aa8db Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:24:34 +0200 Subject: [PATCH 13/71] Merge branch 'next' into drizzle --- .gitattributes | 2 + .gitignore | 1 + cli/.prettierrc.cjs | 1 + cli/CHANGELOG.md | 28 ++ cli/package.json | 4 +- cli/src/cli/index.ts | 329 +++++++++--------- cli/src/helpers/git.ts | 12 +- cli/src/helpers/installDependencies.ts | 4 +- cli/src/helpers/installPackages.ts | 4 +- cli/src/helpers/logNextSteps.ts | 8 +- cli/src/helpers/scaffoldProject.ts | 12 +- cli/src/helpers/setImportAlias.ts | 2 +- cli/src/index.ts | 6 +- cli/src/installers/drizzle.ts | 63 +++- cli/src/installers/envVars.ts | 4 +- cli/src/installers/index.ts | 15 +- cli/src/installers/nextAuth.ts | 2 +- cli/src/installers/prisma.ts | 2 +- cli/src/installers/trpc.ts | 4 +- cli/src/utils/addPackageDependency.ts | 2 +- cli/src/utils/isTTYError.ts | 5 + cli/src/utils/parseNameAndPath.ts | 5 +- cli/src/utils/removeTrailingSlash.ts | 7 + cli/src/utils/renderVersionWarning.ts | 6 +- cli/src/utils/validateAppName.ts | 7 +- cli/src/utils/validateImportAlias.ts | 3 +- cli/template/base/next.config.mjs | 1 + cli/template/base/src/pages/index.tsx | 7 +- .../extras/src/env/with-auth-prisma.mjs | 2 +- cli/template/extras/src/env/with-auth.mjs | 2 +- .../extras/src/pages/api/trpc/[trpc].ts | 2 +- .../src/pages/index/with-auth-trpc-tw.tsx | 13 +- .../extras/src/pages/index/with-auth-trpc.tsx | 13 +- .../extras/src/pages/index/with-trpc-tw.tsx | 7 +- .../extras/src/pages/index/with-trpc.tsx | 7 +- .../extras/src/pages/index/with-tw.tsx | 7 +- .../extras/src/server/auth/with-drizzle.ts | 16 +- .../src/server/db/drizzle-schema-auth.ts | 6 +- .../src/server/db/drizzle-schema-base.ts | 2 +- pnpm-lock.yaml | 23 ++ www/src/components/docs/companyList.tsx | 5 + .../components/navigation/githubIcon.astro | 2 +- www/src/pages/en/faq.mdx | 3 +- www/src/pages/en/usage/env-variables.mdx | 34 +- www/src/pages/zh-hans/t3-collection.mdx | 3 +- 45 files changed, 422 insertions(+), 271 deletions(-) create mode 100644 .gitattributes create mode 100644 cli/src/utils/isTTYError.ts create mode 100644 cli/src/utils/removeTrailingSlash.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..99915e35f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# mdx +*.mdx linguist-detectable=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 31c8eed413..0147b2ae75 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ next-env.d.ts tmp/ temp/ .docusaurus +*.tsbuildinfo # MAC ._* diff --git a/cli/.prettierrc.cjs b/cli/.prettierrc.cjs index 0d16b31203..773d237852 100644 --- a/cli/.prettierrc.cjs +++ b/cli/.prettierrc.cjs @@ -5,6 +5,7 @@ const config = { ...baseConfig, plugins: [...baseConfig.plugins, "prettier-plugin-tailwindcss"], tailwindConfig: "./template/extras/config/tailwind.config.ts", + trailingComma: "es5", }; module.exports = config; diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index c17a42e47d..5e849afa1a 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 7.15.0 + +### Minor Changes + +- [#1484](https://github.com/t3-oss/create-t3-app/pull/1484) [`23a9d60`](https://github.com/t3-oss/create-t3-app/commit/23a9d60cd013c40d76ab96d0340425e1e3d8efa2) Thanks [@c-ehrlich](https://github.com/c-ehrlich)! - reminder to git commit after creating an application with the CLI + +### Patch Changes + +- [#1493](https://github.com/t3-oss/create-t3-app/pull/1493) [`a230d9f`](https://github.com/t3-oss/create-t3-app/commit/a230d9f7bb3a78669f2003ae9084c868f06639b7) Thanks [@dcottr](https://github.com/dcottr)! - Remove trailing newlines in generated app that aren't allowed by the generated prettier config + +## 7.14.1 + +### Patch Changes + +- [#1479](https://github.com/t3-oss/create-t3-app/pull/1479) [`bb7324c`](https://github.com/t3-oss/create-t3-app/commit/bb7324c9503995949c61c0a5abe736c38f07b815) Thanks [@c-ehrlich](https://github.com/c-ehrlich)! - use custom error class for IsTTYError + +## 7.14.0 + +### Minor Changes + +- [#1466](https://github.com/t3-oss/create-t3-app/pull/1466) [`e8b68d9`](https://github.com/t3-oss/create-t3-app/commit/e8b68d92af093361bf73eed7eacd7ed6848500c3) Thanks [@brunoeduardodev](https://github.com/brunoeduardodev)! - Ignore trailing slashes when prompting the app name. + +## 7.13.2 + +### Patch Changes + +- [#1469](https://github.com/t3-oss/create-t3-app/pull/1469) [`547f504`](https://github.com/t3-oss/create-t3-app/commit/547f504b91c3da9b6419ea7f9f43d03e6c243839) Thanks [@ericshively](https://github.com/ericshively)! - Replace React.FC with basic function syntax + ## 7.13.1 ### Patch Changes diff --git a/cli/package.json b/cli/package.json index f4d851dfb4..6c3e952163 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "create-t3-app", - "version": "7.13.1", + "version": "7.15.0", "description": "Create web application with the t3 stack", "license": "MIT", "repository": { @@ -41,6 +41,8 @@ "pub:release": "pnpm build && npm publish" }, "dependencies": { + "@clack/core": "^0.3.2", + "@clack/prompts": "^0.6.3", "@ianvs/prettier-plugin-sort-imports": "^3.7.2", "chalk": "5.2.0", "commander": "^10.0.0", diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index c000330b61..6bb4f66b69 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -1,11 +1,14 @@ +import * as p from "@clack/prompts"; import chalk from "chalk"; import { Command } from "commander"; import inquirer from "inquirer"; import { CREATE_T3_APP, DEFAULT_APP_NAME } from "~/consts.js"; import { type AvailablePackages } from "~/installers/index.js"; -import { availablePackages } from "~/installers/index.js"; +// import { availablePackages } from "~/installers/index.js"; import { getVersion } from "~/utils/getT3Version.js"; import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; +// import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; +import { IsTTYError } from "~/utils/isTTYError.js"; import { logger } from "~/utils/logger.js"; import { validateAppName } from "~/utils/validateAppName.js"; import { validateImportAlias } from "~/utils/validateImportAlias.js"; @@ -25,7 +28,7 @@ interface CliFlags { /** @internal Used in CI. */ prisma: boolean; /** @internal Used in CI. */ - drizzle: boolean; + drizzle: boolean | "pscale" | "pg"; /** @internal Used in CI. */ nextAuth: boolean; } @@ -53,33 +56,30 @@ const defaultOptions: CliResults = { }, }; -export const runCli = async () => { +export const runCli = async (): Promise => { const cliResults = defaultOptions; - const program = new Command().name(CREATE_T3_APP); - - // TODO: This doesn't return anything typesafe. Research other options? - // Emulate from: https://github.com/Schniz/soundtype-commander - program + const program = new Command() + .name(CREATE_T3_APP) .description("A CLI for creating web applications with the t3 stack") .argument( "[dir]", - "The name of the application, as well as the name of the directory to create", + "The name of the application, as well as the name of the directory to create" ) .option( "--noGit", "Explicitly tell the CLI to not initialize a new git repo in the project", - false, + false ) .option( "--noInstall", "Explicitly tell the CLI to not run the package manager's install command", - false, + false ) .option( "-y, --default", "Bypass the CLI and use all default options to bootstrap a new t3-app", - false, + false ) /** START CI-FLAGS */ /** @@ -91,37 +91,47 @@ export const runCli = async () => { .option( "--tailwind [boolean]", "Experimental: Boolean value if we should install Tailwind CSS. Must be used in conjunction with `--CI`.", - (value) => !!value && value !== "false", + (value) => !!value && value !== "false" ) /** @experimental Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( "--nextAuth [boolean]", "Experimental: Boolean value if we should install NextAuth.js. Must be used in conjunction with `--CI`.", - (value) => !!value && value !== "false", + (value) => !!value && value !== "false" ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( "--prisma [boolean]", "Experimental: Boolean value if we should install Prisma. Must be used in conjunction with `--CI`.", - (value) => !!value && value !== "false", + (value) => !!value && value !== "false" ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( - "--drizzle [boolean]", - "Experimental: Boolean value if we should install Drizzle. Must be used in conjunction with `--CI`.", - (value) => !!value && value !== "false", + "--drizzle [string]", + "Experimental: What SQL Dialect to use if using Drizzle. Must be used in conjunction with `--CI`.", + (value) => { + if (!value || value === "false") { + return false; + } + if (["pg", "pscale"].includes(value)) { + return value; + } + throw new Error( + `Invalid value for --drizzle. Expected: 'none', 'pg' or 'pscale', got '${value}'` + ); + } ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( "--trpc [boolean]", "Experimental: Boolean value if we should install tRPC. Must be used in conjunction with `--CI`.", - (value) => !!value && value !== "false", + (value) => !!value && value !== "false" ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( "-i, --import-alias", "Explicitly tell the CLI to use a custom import alias", - defaultOptions.flags.importAlias, + defaultOptions.flags.importAlias ) /** END CI-FLAGS */ .version(getVersion(), "-v, --version", "Display the version number") @@ -130,10 +140,10 @@ export const runCli = async () => { `\n The t3 stack was inspired by ${chalk .hex("#E8DCFF") .bold( - "@t3dotgg", + "@t3dotgg" )} and has been used to build awesome fullstack applications like ${chalk .hex("#E24A8D") - .underline("https://ping.gg")} \n`, + .underline("https://ping.gg")} \n` ) .parse(process.argv); @@ -154,23 +164,32 @@ export const runCli = async () => { cliResults.flags = program.opts(); /** @internal Used for CI E2E tests. */ - let CIMode = false; if (cliResults.flags.CI) { - CIMode = true; cliResults.packages = []; if (cliResults.flags.trpc) cliResults.packages.push("trpc"); if (cliResults.flags.tailwind) cliResults.packages.push("tailwind"); if (cliResults.flags.prisma) cliResults.packages.push("prisma"); - if (cliResults.flags.drizzle) cliResults.packages.push("drizzle"); + if (cliResults.flags.drizzle === "pg") + cliResults.packages.push("drizzle-pg"); + if (cliResults.flags.drizzle === "pscale") + cliResults.packages.push("drizzle-pscale"); if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); if (cliResults.flags.prisma && cliResults.flags.drizzle) { console.warn( - "Incompatible combination Prisma + Drizzle. Falling back to Prisma only.", + "Incompatible combination Prisma + Drizzle. Falling back to Prisma only." ); cliResults.flags.drizzle = false; - cliResults.packages.splice(cliResults.packages.indexOf("drizzle"), 1); + cliResults.packages = cliResults.packages.filter( + (pkg) => pkg !== "drizzle-pg" && pkg !== "drizzle-pscale" + ); } + + return cliResults; + } + + if (cliResults.flags.default) { + return cliResults; } // Explained below why this is in a try/catch block @@ -180,37 +199,128 @@ export const runCli = async () => { using Git Bash. If that's that case, please use Git Bash from another terminal, such as Windows Terminal. Alternatively, you can provide the arguments from the CLI directly: https://create.t3.gg/en/installation#experimental-usage to skip the prompts.`); - const error = new Error("Non-interactive environment"); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (error as any).isTTYError = true; - throw error; + throw new IsTTYError("Non-interactive environment"); } // if --CI flag is set, we are running in CI mode and should not prompt the user - // if --default flag is set, we should not prompt the user - if (!cliResults.flags.default && !CIMode) { - if (!cliProvidedName) { - cliResults.appName = await promptAppName(); - } - await promptLanguage(); - cliResults.packages = await promptPackages(); - if (!cliResults.flags.noGit) { - cliResults.flags.noGit = !(await promptGit()); + const pkgManager = getUserPkgManager(); + + const project = await p.group( + { + ...(!cliProvidedName && { + name: () => + p.text({ + message: "What will your project be called?", + defaultValue: cliProvidedName, + validate: validateAppName, + }), + }), + language: () => { + return p.select({ + message: "Will you be using TypeScript or JavaScript?", + options: [ + { value: "typescript", label: "TypeScript" }, + { value: "javascript", label: "JavaScript" }, + ], + initialValue: "typescript", + }); + }, + _: ({ results }) => + results.language === "javascript" + ? p.note(chalk.redBright("Wrong answer, using TypeScript instead")) + : undefined, + styling: () => { + return p.confirm({ + message: "Will you be using Tailwind CSS for styling?", + }); + }, + trpc: () => { + return p.confirm({ + message: "Would you like to use tRPC?", + }); + }, + authentication: () => { + return p.select({ + message: "What authentication provider would you like to use?", + options: [ + { value: "none", label: "None" }, + { value: "next-auth", label: "NextAuth.js" }, + // Maybe later + // { value: "clerk", label: "Clerk" }, + ], + initialValue: "none", + }); + }, + database: () => { + return p.select({ + message: "What database ORM would you like to use?", + options: [ + { value: "none", label: "None" }, + { value: "prisma", label: "Prisma" }, + { value: "drizzle-pscale", label: "Drizzle w/ PlanetScale" }, + { value: "drizzle-pg", label: "Drizzle w/ PostgreSQL" }, + ], + initialValue: "none", + }); + }, + ...(!cliResults.flags.noGit && { + git: () => { + return p.confirm({ + message: + "Should we initialize a Git repository and stage the changes?", + initialValue: !defaultOptions.flags.noGit, + }); + }, + }), + ...(!cliResults.flags.noInstall && { + install: () => { + return p.confirm({ + message: + `Should we run '${pkgManager}` + + (pkgManager === "yarn" ? `'?` : ` install' for you?`), + initialValue: !defaultOptions.flags.noInstall, + }); + }, + }), + importAlias: () => { + return p.text({ + message: "What import alias would you like to use?", + defaultValue: defaultOptions.flags.importAlias, + placeholder: defaultOptions.flags.importAlias, + validate: validateImportAlias, + }); + }, + }, + { + onCancel() { + process.exit(1); + }, } - - if (!cliResults.flags.noInstall) { - cliResults.flags.noInstall = !(await promptInstall()); - } - - cliResults.flags.importAlias = await promptImportAlias(); - } + ); + + const packages: AvailablePackages[] = []; + if (project.styling) packages.push("tailwind"); + if (project.trpc) packages.push("trpc"); + if (project.authentication === "next-auth") packages.push("nextAuth"); + if (project.database === "prisma") packages.push("prisma"); + if (project.database === "drizzle-pscale") packages.push("drizzle-pscale"); + if (project.database === "drizzle-pg") packages.push("drizzle-pg"); + + return { + appName: project.name ?? cliResults.appName, + packages, + flags: { + ...cliResults.flags, + noGit: !project.git ?? cliResults.flags.noGit, + noInstall: !project.install ?? cliResults.flags.noInstall, + importAlias: project.importAlias ?? cliResults.flags.importAlias, + }, + }; } catch (err) { - // If the user is not calling create-t3-app from an interactive terminal, inquirer will throw an error with isTTYError = true + // If the user is not calling create-t3-app from an interactive terminal, inquirer will throw an IsTTYError // If this happens, we catch the error, tell the user what has happened, and then continue to run the program with a default t3 app - // Otherwise we have to do some fancy namespace extension logic on the Error type which feels overkill for one line - // eslint-disable-next-line @typescript-eslint/no-explicit-any - if (err instanceof Error && (err as any).isTTYError) { + if (err instanceof IsTTYError) { logger.warn(` ${CREATE_T3_APP} needs an interactive terminal to provide options`); @@ -236,120 +346,3 @@ export const runCli = async () => { return cliResults; }; - -const promptAppName = async (): Promise => { - const { appName } = await inquirer.prompt>({ - name: "appName", - type: "input", - message: "What will your project be called?", - default: defaultOptions.appName, - validate: validateAppName, - transformer: (input: string) => { - return input.trim(); - }, - }); - - return appName; -}; - -const promptLanguage = async (): Promise => { - const { language } = await inquirer.prompt<{ language: string }>({ - name: "language", - type: "list", - message: "Will you be using TypeScript or JavaScript?", - choices: [ - { name: "TypeScript", value: "typescript", short: "TypeScript" }, - { name: "JavaScript", value: "javascript", short: "JavaScript" }, - ], - default: "typescript", - }); - - if (language === "javascript") { - logger.error("Wrong answer, using TypeScript instead..."); - } else { - logger.success("Good choice! Using TypeScript!"); - } -}; - -const promptPackages = async (): Promise => { - const { packages } = await inquirer.prompt>({ - name: "packages", - type: "checkbox", - message: "Which packages would you like to enable?", - choices: availablePackages - .filter((pkg) => pkg !== "envVariables") // don't prompt for env-vars - .map((pkgName) => ({ - name: pkgName, - checked: false, - })), - validate: (input: string[]) => { - if (input.includes("prisma") && input.includes("drizzle")) { - return "You cannot select both Prisma and Drizzle in the same app."; - } - return true; - }, - }); - - return packages; -}; - -const promptGit = async (): Promise => { - const { git } = await inquirer.prompt<{ git: boolean }>({ - name: "git", - type: "confirm", - message: "Initialize a new git repository?", - default: true, - }); - - if (git) { - logger.success("Nice one! Initializing repository!"); - } else { - logger.info("Sounds good! You can come back and run git init later."); - } - - return git; -}; - -const promptInstall = async (): Promise => { - const pkgManager = getUserPkgManager(); - - const { install } = await inquirer.prompt<{ install: boolean }>({ - name: "install", - type: "confirm", - message: - `Would you like us to run '${pkgManager}` + - (pkgManager === "yarn" ? `'?` : ` install'?`), - default: true, - }); - - if (install) { - logger.success("Alright. We'll install the dependencies for you!"); - } else { - if (pkgManager === "yarn") { - logger.info( - `No worries. You can run '${pkgManager}' later to install the dependencies.`, - ); - } else { - logger.info( - `No worries. You can run '${pkgManager} install' later to install the dependencies.`, - ); - } - } - - return install; -}; - -const promptImportAlias = async (): Promise => { - const { importAlias } = await inquirer.prompt>({ - name: "importAlias", - type: "input", - message: "What import alias would you like configured?", - default: defaultOptions.flags.importAlias, - validate: validateImportAlias, - transformer: (input: string) => { - return input.trim(); - }, - }); - - return importAlias; -}; diff --git a/cli/src/helpers/git.ts b/cli/src/helpers/git.ts index 54e86ce12f..93c3b8e47a 100644 --- a/cli/src/helpers/git.ts +++ b/cli/src/helpers/git.ts @@ -77,7 +77,7 @@ export const initializeGit = async (projectDir: string) => { name: "overwriteGit", type: "confirm", message: `${chalk.redBright.bold( - "Warning:", + "Warning:" )} Git is already initialized in "${dirName}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`, default: false, }); @@ -96,7 +96,7 @@ export const initializeGit = async (projectDir: string) => { name: "initializeChildGitRepo", type: "confirm", message: `${chalk.redBright.bold( - "Warning:", + "Warning:" )} "${dirName}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`, default: false, }); @@ -128,15 +128,15 @@ export const initializeGit = async (projectDir: string) => { await execa("git", ["add", "."], { cwd: projectDir }); spinner.succeed( `${chalk.green("Successfully initialized and staged")} ${chalk.green.bold( - "git", - )}\n`, + "git" + )}\n` ); } catch (error) { // Safeguard, should be unreachable spinner.fail( `${chalk.bold.red( - "Failed:", - )} could not initialize git. Update git to the latest version!\n`, + "Failed:" + )} could not initialize git. Update git to the latest version!\n` ); } }; diff --git a/cli/src/helpers/installDependencies.ts b/cli/src/helpers/installDependencies.ts index 7c12f9e38e..a0c3824729 100644 --- a/cli/src/helpers/installDependencies.ts +++ b/cli/src/helpers/installDependencies.ts @@ -14,7 +14,7 @@ type Options = { /*eslint-disable @typescript-eslint/no-floating-promises*/ const runInstallCommand = async ( pkgManager: PackageManager, - projectDir: string, + projectDir: string ): Promise => { switch (pkgManager) { // When using npm, inherit the stderr stream so that the progress bar is shown @@ -77,6 +77,6 @@ export const installDependencies = async ({ projectDir }: Options) => { // If the spinner was used to show the progress, use succeed method on it // If not, use the succeed on a new spinner (installSpinner || ora()).succeed( - chalk.green("Successfully installed dependencies!\n"), + chalk.green("Successfully installed dependencies!\n") ); }; diff --git a/cli/src/helpers/installPackages.ts b/cli/src/helpers/installPackages.ts index d65eb20d7a..1f5b4089b6 100644 --- a/cli/src/helpers/installPackages.ts +++ b/cli/src/helpers/installPackages.ts @@ -20,8 +20,8 @@ export const installPackages = (options: InstallPackagesOptions) => { pkgOpts.installer(options); spinner.succeed( chalk.green( - `Successfully setup boilerplate for ${chalk.green.bold(name)}`, - ), + `Successfully setup boilerplate for ${chalk.green.bold(name)}` + ) ); } } diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index 47ed848183..4eea03586a 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -23,12 +23,12 @@ export const logNextSteps = ({ } if (packages?.prisma.inUse) { - logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} db:push`); + logger.info(` ${pkgManager === "npm" ? "npx" : pkgManager} db:push`); } if (packages?.drizzle.inUse) { logger.info( - ` ${pkgManager === "npm" ? "npx" : pkgManager} drizzle-kit push:mysql`, + ` ${pkgManager === "npm" ? "npx" : pkgManager} drizzle-kit push:mysql` ); } @@ -37,7 +37,9 @@ export const logNextSteps = ({ if (packages?.drizzle.inUse) { logger.warn( `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, - `\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.`, + `\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.` ); } + + logger.info(` git commit -m "initial commit"`); }; diff --git a/cli/src/helpers/scaffoldProject.ts b/cli/src/helpers/scaffoldProject.ts index 2c46b2fa36..466f2c457b 100644 --- a/cli/src/helpers/scaffoldProject.ts +++ b/cli/src/helpers/scaffoldProject.ts @@ -28,9 +28,7 @@ export const scaffoldProject = async ({ if (fs.readdirSync(projectDir).length === 0) { if (projectName !== ".") spinner.info( - `${chalk.cyan.bold( - projectName, - )} exists but is empty, continuing...\n`, + `${chalk.cyan.bold(projectName)} exists but is empty, continuing...\n` ); } else { spinner.stopAndPersist(); @@ -40,7 +38,7 @@ export const scaffoldProject = async ({ name: "overwriteDir", type: "list", message: `${chalk.redBright.bold("Warning:")} ${chalk.cyan.bold( - projectName, + projectName )} already exists and isn't empty. How would you like to proceed?`, choices: [ { @@ -87,7 +85,7 @@ export const scaffoldProject = async ({ if (overwriteDir === "clear") { spinner.info( - `Emptying ${chalk.cyan.bold(projectName)} and creating t3 app..\n`, + `Emptying ${chalk.cyan.bold(projectName)} and creating t3 app..\n` ); fs.emptyDirSync(projectDir); } @@ -99,13 +97,13 @@ export const scaffoldProject = async ({ fs.copySync(srcDir, projectDir); fs.renameSync( path.join(projectDir, "_gitignore"), - path.join(projectDir, ".gitignore"), + path.join(projectDir, ".gitignore") ); const scaffoldedName = projectName === "." ? "App" : chalk.cyan.bold(projectName); spinner.succeed( - `${scaffoldedName} ${chalk.green("scaffolded successfully!")}\n`, + `${scaffoldedName} ${chalk.green("scaffolded successfully!")}\n` ); }; diff --git a/cli/src/helpers/setImportAlias.ts b/cli/src/helpers/setImportAlias.ts index bbb4622a26..8cc08d1782 100644 --- a/cli/src/helpers/setImportAlias.ts +++ b/cli/src/helpers/setImportAlias.ts @@ -4,7 +4,7 @@ import path from "path"; function replaceTextInFiles( directoryPath: string, search: string, - replacement: string, + replacement: string ): void { const files = fs.readdirSync(directoryPath); diff --git a/cli/src/index.ts b/cli/src/index.ts index 66bca71a87..3171103c6c 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -49,7 +49,7 @@ const main = async () => { // Write name to package.json const pkgJson = fs.readJSONSync( - path.join(projectDir, "package.json"), + path.join(projectDir, "package.json") ) as CT3APackageJSON; pkgJson.name = scopedAppName; pkgJson.ct3aMetadata = { initVersion: getVersion() }; @@ -69,7 +69,7 @@ const main = async () => { // Rename _eslintrc.json to .eslintrc.json - we use _eslintrc.json to avoid conflicts with the monorepos linter fs.renameSync( path.join(projectDir, "_eslintrc.cjs"), - path.join(projectDir, ".eslintrc.cjs"), + path.join(projectDir, ".eslintrc.cjs") ); if (!noGit) { @@ -87,7 +87,7 @@ main().catch((err) => { logger.error(err); } else { logger.error( - "An unknown error has occurred. Please open an issue on github with the below:", + "An unknown error has occurred. Please open an issue on github with the below:" ); console.log(err); } diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 0c2a3d6249..4e43983a03 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -5,7 +5,20 @@ import { PKG_ROOT } from "~/consts.js"; import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; -export const drizzleInstaller: Installer = ({ projectDir, packages }) => { +export const getDrizzleInstaller = ( + dialect: "sqlite" | "pscale" +): Installer => { + switch (dialect) { + case "sqlite": + return sqliteDrizzleInstaller; + case "pscale": + return pscaleDrizzleInstaller; + default: + throw new Error(`Invalid dialect: ${dialect}`); + } +}; + +const pscaleDrizzleInstaller: Installer = ({ projectDir, packages }) => { addPackageDependency({ projectDir, dependencies: ["drizzle-kit", "dotenv"], @@ -27,7 +40,7 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { "src/server/db", packages?.nextAuth.inUse ? "drizzle-schema-auth.ts" - : "drizzle-schema-base.ts", + : "drizzle-schema-base.ts" ); const schemaDest = path.join(projectDir, "src/server/db/schema.ts"); @@ -50,3 +63,49 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { spaces: 2, }); }; + +const sqliteDrizzleInstaller: Installer = ({ projectDir, packages }) => { + addPackageDependency({ + projectDir, + dependencies: ["drizzle-kit", "dotenv", "@types/pg"], + devMode: true, + }); + addPackageDependency({ + projectDir, + dependencies: ["drizzle-orm", "pg"], + devMode: false, + }); + + const extrasDir = path.join(PKG_ROOT, "template/extras"); + + const configFile = path.join(extrasDir, "config/drizzle.config.ts"); + const configDest = path.join(projectDir, "drizzle.config.ts"); + + const schemaSrc = path.join( + extrasDir, + "src/server/db", + packages?.nextAuth.inUse + ? "drizzle-schema-auth.ts" + : "drizzle-schema-base.ts" + ); + const schemaDest = path.join(projectDir, "src/server/db/schema.ts"); + + const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); + const clientDest = path.join(projectDir, "src/server/db/index.ts"); + + // add db:push script to package.json + const packageJsonPath = path.join(projectDir, "package.json"); + + const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; + packageJsonContent.scripts = { + ...packageJsonContent.scripts, + "db:push": "drizzle-kit push:sqlite", + }; + + fs.copySync(configFile, configDest); + fs.copySync(schemaSrc, schemaDest); + fs.copySync(clientSrc, clientDest); + fs.writeJSONSync(packageJsonPath, packageJsonContent, { + spaces: 2, + }); +}; diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index d11c40f8d5..1a48f74670 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -23,7 +23,7 @@ export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const envSchemaSrc = path.join( PKG_ROOT, "template/extras/src/env", - envFile, + envFile ); const envSchemaDest = path.join(projectDir, "src/env.mjs"); fs.copySync(envSchemaSrc, envSchemaDest); @@ -39,7 +39,7 @@ export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const getEnvContent = ( usingAuth: boolean, usingPrisma: boolean, - usingDrizzle: boolean, + usingDrizzle: boolean ) => { let content = ` # When adding additional environment variables, the schema in "/src/env.mjs" diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 235ca5145f..b104bb1b01 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -11,7 +11,8 @@ import { type PackageManager } from "~/utils/getUserPkgManager.js"; export const availablePackages = [ "nextAuth", "prisma", - "drizzle", + "drizzle-pscale", + "drizzle-pg", "tailwind", "trpc", "envVariables", @@ -36,7 +37,7 @@ export type PkgInstallerMap = { }; export const buildPkgInstallerMap = ( - packages: AvailablePackages[], + packages: AvailablePackages[] ): PkgInstallerMap => ({ nextAuth: { inUse: packages.includes("nextAuth"), @@ -46,9 +47,13 @@ export const buildPkgInstallerMap = ( inUse: packages.includes("prisma"), installer: prismaInstaller, }, - drizzle: { - inUse: packages.includes("drizzle"), - installer: drizzleInstaller, + "drizzle-pg": { + inUse: packages.includes("drizzle-pg"), + installer: getDrizzleInstaller("pg"), + }, + "drizzle-pscale": { + inUse: packages.includes("drizzle-pscale"), + installer: getDrizzleInstaller("pscale"), }, tailwind: { inUse: packages.includes("tailwind"), diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index d7ba48ae63..f7a4b38ff7 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -33,7 +33,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { ? "with-prisma.ts" : usingDrizzle ? "with-drizzle.ts" - : "base.ts", + : "base.ts" ); const authConfigDest = path.join(projectDir, "src/server/auth.ts"); diff --git a/cli/src/installers/prisma.ts b/cli/src/installers/prisma.ts index 8387a3d5b4..00686f4866 100644 --- a/cli/src/installers/prisma.ts +++ b/cli/src/installers/prisma.ts @@ -22,7 +22,7 @@ export const prismaInstaller: Installer = ({ projectDir, packages }) => { const schemaSrc = path.join( extrasDir, "prisma/schema", - packages?.nextAuth.inUse ? "with-auth.prisma" : "base.prisma", + packages?.nextAuth.inUse ? "with-auth.prisma" : "base.prisma" ); const schemaDest = path.join(projectDir, "prisma/schema.prisma"); diff --git a/cli/src/installers/trpc.ts b/cli/src/installers/trpc.ts index 2a77e2ecb7..4db13be0b2 100644 --- a/cli/src/installers/trpc.ts +++ b/cli/src/installers/trpc.ts @@ -61,11 +61,11 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const exampleRouterSrc = path.join( extrasDir, "src/server/api/routers/example", - exampleRouterFile, + exampleRouterFile ); const exampleRouterDest = path.join( projectDir, - "src/server/api/routers/example.ts", + "src/server/api/routers/example.ts" ); fs.copySync(apiHandlerSrc, apiHandlerDest); diff --git a/cli/src/utils/addPackageDependency.ts b/cli/src/utils/addPackageDependency.ts index df77d129d1..2784502d9a 100644 --- a/cli/src/utils/addPackageDependency.ts +++ b/cli/src/utils/addPackageDependency.ts @@ -15,7 +15,7 @@ export const addPackageDependency = (opts: { const { dependencies, devMode, projectDir } = opts; const pkgJson = fs.readJSONSync( - path.join(projectDir, "package.json"), + path.join(projectDir, "package.json") ) as PackageJson; dependencies.forEach((pkgName) => { diff --git a/cli/src/utils/isTTYError.ts b/cli/src/utils/isTTYError.ts new file mode 100644 index 0000000000..d227b82f66 --- /dev/null +++ b/cli/src/utils/isTTYError.ts @@ -0,0 +1,5 @@ +export class IsTTYError extends Error { + constructor(msg: string) { + super(msg); + } +} diff --git a/cli/src/utils/parseNameAndPath.ts b/cli/src/utils/parseNameAndPath.ts index a620451130..829741103d 100644 --- a/cli/src/utils/parseNameAndPath.ts +++ b/cli/src/utils/parseNameAndPath.ts @@ -1,3 +1,4 @@ +import { removeTrailingSlash } from "./removeTrailingSlash.js"; import pathModule from "path"; /** @@ -15,7 +16,9 @@ import pathModule from "path"; * - dir/@mono/app => ["@mono/app", "dir/app"] * - dir/app => ["app", "dir/app"] */ -export const parseNameAndPath = (input: string) => { +export const parseNameAndPath = (rawInput: string) => { + const input = removeTrailingSlash(rawInput); + const paths = input.split("/"); let appName = paths[paths.length - 1]; diff --git a/cli/src/utils/removeTrailingSlash.ts b/cli/src/utils/removeTrailingSlash.ts new file mode 100644 index 0000000000..c66d198edc --- /dev/null +++ b/cli/src/utils/removeTrailingSlash.ts @@ -0,0 +1,7 @@ +export const removeTrailingSlash = (input: string) => { + if (input.length > 1 && input.endsWith("/")) { + input = input.slice(0, -1); + } + + return input; +}; diff --git a/cli/src/utils/renderVersionWarning.ts b/cli/src/utils/renderVersionWarning.ts index 1af23c0caa..5029510afc 100644 --- a/cli/src/utils/renderVersionWarning.ts +++ b/cli/src/utils/renderVersionWarning.ts @@ -14,7 +14,7 @@ export const renderVersionWarning = (npmVersion: string) => { logger.warn(" Please report any bugs you encounter."); } else if (currentVersion.includes("next")) { logger.warn( - " You are running create-t3-app with the @next tag which is no longer maintained.", + " You are running create-t3-app with the @next tag which is no longer maintained." ); logger.warn(" Please run the CLI with @latest instead."); } else if (currentVersion !== npmVersion) { @@ -23,7 +23,7 @@ export const renderVersionWarning = (npmVersion: string) => { " Your version:", currentVersion + ".", "Latest version in the npm registry:", - npmVersion, + npmVersion ); logger.warn(" Please run the CLI with @latest to get the latest updates."); } @@ -56,7 +56,7 @@ function checkForLatestVersion(): Promise { } else { reject(); } - }, + } ) .on("error", () => { // logger.error("Unable to check for latest version."); diff --git a/cli/src/utils/validateAppName.ts b/cli/src/utils/validateAppName.ts index 12a8314e39..7f05949582 100644 --- a/cli/src/utils/validateAppName.ts +++ b/cli/src/utils/validateAppName.ts @@ -1,8 +1,11 @@ +import { removeTrailingSlash } from "./removeTrailingSlash.js"; + const validationRegExp = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/; //Validate a string against allowed package.json names -export const validateAppName = (input: string) => { +export const validateAppName = (rawInput: string) => { + const input = removeTrailingSlash(rawInput); const paths = input.split("/"); // If the first part is a @, it's a scoped package @@ -14,7 +17,7 @@ export const validateAppName = (input: string) => { } if (input === "." || validationRegExp.test(appName ?? "")) { - return true; + return; } else { return "App name must consist of only lowercase alphanumeric characters, '-', and '_'"; } diff --git a/cli/src/utils/validateImportAlias.ts b/cli/src/utils/validateImportAlias.ts index d762a9c951..bd33ca6197 100644 --- a/cli/src/utils/validateImportAlias.ts +++ b/cli/src/utils/validateImportAlias.ts @@ -1,7 +1,6 @@ export const validateImportAlias = (input: string) => { if (input.startsWith(".") || input.startsWith("/")) { return "Import alias can't start with '.' or '/'"; - } else { - return true; } + return; }; diff --git a/cli/template/base/next.config.mjs b/cli/template/base/next.config.mjs index d921057fcf..654e725620 100644 --- a/cli/template/base/next.config.mjs +++ b/cli/template/base/next.config.mjs @@ -19,4 +19,5 @@ const config = { defaultLocale: "en", }, }; + export default config; diff --git a/cli/template/base/src/pages/index.tsx b/cli/template/base/src/pages/index.tsx index 35f4e30e1e..8af8ec8b10 100644 --- a/cli/template/base/src/pages/index.tsx +++ b/cli/template/base/src/pages/index.tsx @@ -1,9 +1,8 @@ import styles from "./index.module.css"; -import { type NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; -const Home: NextPage = () => { +export default function Home() { return ( <> @@ -44,6 +43,4 @@ const Home: NextPage = () => { ); -}; - -export default Home; +} diff --git a/cli/template/extras/src/env/with-auth-prisma.mjs b/cli/template/extras/src/env/with-auth-prisma.mjs index 30fa238989..58bc43a153 100644 --- a/cli/template/extras/src/env/with-auth-prisma.mjs +++ b/cli/template/extras/src/env/with-auth-prisma.mjs @@ -18,7 +18,7 @@ export const env = createEnv({ // Since NextAuth.js automatically uses the VERCEL_URL if present. (str) => process.env.VERCEL_URL ?? str, // VERCEL_URL doesn't include `https` so it cant be validated as a URL - process.env.VERCEL ? z.string().min(1) : z.string().url(), + process.env.VERCEL ? z.string().min(1) : z.string().url() ), // Add `.min(1) on ID and SECRET if you want to make sure they're not empty DISCORD_CLIENT_ID: z.string(), diff --git a/cli/template/extras/src/env/with-auth.mjs b/cli/template/extras/src/env/with-auth.mjs index 81853157ea..71808934f2 100644 --- a/cli/template/extras/src/env/with-auth.mjs +++ b/cli/template/extras/src/env/with-auth.mjs @@ -17,7 +17,7 @@ export const env = createEnv({ // Since NextAuth.js automatically uses the VERCEL_URL if present. (str) => process.env.VERCEL_URL ?? str, // VERCEL_URL doesn't include `https` so it cant be validated as a URL - process.env.VERCEL ? z.string().min(1) : z.string().url(), + process.env.VERCEL ? z.string().min(1) : z.string().url() ), // Add `.min(1) on ID and SECRET if you want to make sure they're not empty DISCORD_CLIENT_ID: z.string(), diff --git a/cli/template/extras/src/pages/api/trpc/[trpc].ts b/cli/template/extras/src/pages/api/trpc/[trpc].ts index dc36ccf780..6c53746bdc 100644 --- a/cli/template/extras/src/pages/api/trpc/[trpc].ts +++ b/cli/template/extras/src/pages/api/trpc/[trpc].ts @@ -11,7 +11,7 @@ export default createNextApiHandler({ env.NODE_ENV === "development" ? ({ path, error }) => { console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}`, + `❌ tRPC failed on ${path ?? ""}: ${error.message}` ); } : undefined, diff --git a/cli/template/extras/src/pages/index/with-auth-trpc-tw.tsx b/cli/template/extras/src/pages/index/with-auth-trpc-tw.tsx index c173f6f985..622d15f683 100644 --- a/cli/template/extras/src/pages/index/with-auth-trpc-tw.tsx +++ b/cli/template/extras/src/pages/index/with-auth-trpc-tw.tsx @@ -1,10 +1,9 @@ -import { type NextPage } from "next"; import { signIn, signOut, useSession } from "next-auth/react"; import Head from "next/head"; import Link from "next/link"; import { api } from "~/utils/api"; -const Home: NextPage = () => { +export default function Home() { const hello = api.example.hello.useQuery({ text: "from tRPC" }); return ( @@ -53,16 +52,14 @@ const Home: NextPage = () => { ); -}; +} -export default Home; - -const AuthShowcase: React.FC = () => { +function AuthShowcase() { const { data: sessionData } = useSession(); const { data: secretMessage } = api.example.getSecretMessage.useQuery( undefined, // no input - { enabled: sessionData?.user !== undefined }, + { enabled: sessionData?.user !== undefined } ); return ( @@ -79,4 +76,4 @@ const AuthShowcase: React.FC = () => { ); -}; +} diff --git a/cli/template/extras/src/pages/index/with-auth-trpc.tsx b/cli/template/extras/src/pages/index/with-auth-trpc.tsx index 1e3484fc02..a6bc542572 100644 --- a/cli/template/extras/src/pages/index/with-auth-trpc.tsx +++ b/cli/template/extras/src/pages/index/with-auth-trpc.tsx @@ -1,11 +1,10 @@ import styles from "./index.module.css"; -import { type NextPage } from "next"; import { signIn, signOut, useSession } from "next-auth/react"; import Head from "next/head"; import Link from "next/link"; import { api } from "~/utils/api"; -const Home: NextPage = () => { +export default function Home() { const hello = api.example.hello.useQuery({ text: "from tRPC" }); return ( @@ -54,16 +53,14 @@ const Home: NextPage = () => { ); -}; +} -export default Home; - -const AuthShowcase: React.FC = () => { +function AuthShowcase() { const { data: sessionData } = useSession(); const { data: secretMessage } = api.example.getSecretMessage.useQuery( undefined, // no input - { enabled: sessionData?.user !== undefined }, + { enabled: sessionData?.user !== undefined } ); return ( @@ -80,4 +77,4 @@ const AuthShowcase: React.FC = () => { ); -}; +} diff --git a/cli/template/extras/src/pages/index/with-trpc-tw.tsx b/cli/template/extras/src/pages/index/with-trpc-tw.tsx index 52cccbe62d..83d9f79e5f 100644 --- a/cli/template/extras/src/pages/index/with-trpc-tw.tsx +++ b/cli/template/extras/src/pages/index/with-trpc-tw.tsx @@ -1,9 +1,8 @@ -import { type NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; import { api } from "~/utils/api"; -const Home: NextPage = () => { +export default function Home() { const hello = api.example.hello.useQuery({ text: "from tRPC" }); return ( @@ -49,6 +48,4 @@ const Home: NextPage = () => { ); -}; - -export default Home; +} diff --git a/cli/template/extras/src/pages/index/with-trpc.tsx b/cli/template/extras/src/pages/index/with-trpc.tsx index 3768eb3583..2cda92c2e2 100644 --- a/cli/template/extras/src/pages/index/with-trpc.tsx +++ b/cli/template/extras/src/pages/index/with-trpc.tsx @@ -1,10 +1,9 @@ import styles from "./index.module.css"; -import { type NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; import { api } from "~/utils/api"; -const Home: NextPage = () => { +export default function Home() { const hello = api.example.hello.useQuery({ text: "from tRPC" }); return ( @@ -50,6 +49,4 @@ const Home: NextPage = () => { ); -}; - -export default Home; +} diff --git a/cli/template/extras/src/pages/index/with-tw.tsx b/cli/template/extras/src/pages/index/with-tw.tsx index 5513c42445..2b6a38787e 100644 --- a/cli/template/extras/src/pages/index/with-tw.tsx +++ b/cli/template/extras/src/pages/index/with-tw.tsx @@ -1,8 +1,7 @@ -import { type NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; -const Home: NextPage = () => { +export default function Home() { return ( <> @@ -43,6 +42,4 @@ const Home: NextPage = () => { ); -}; - -export default Home; +} diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index e2ff11d436..1f018f8eb9 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -167,8 +167,8 @@ export function DrizzleAdapter(): Adapter { .where( and( eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider), - ), + eq(accounts.provider, account.provider) + ) ) .leftJoin(users, eq(accounts.userId, users.id)) .then((res) => res[0]); @@ -196,8 +196,8 @@ export function DrizzleAdapter(): Adapter { .where( and( eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token), - ), + eq(verificationTokens.token, token.token) + ) ) .then((res) => res[0])) ?? null; @@ -206,8 +206,8 @@ export function DrizzleAdapter(): Adapter { .where( and( eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token), - ), + eq(verificationTokens.token, token.token) + ) ); return deletedToken; @@ -230,8 +230,8 @@ export function DrizzleAdapter(): Adapter { .where( and( eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider), - ), + eq(accounts.provider, account.provider) + ) ); return undefined; diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index f049ef3ac3..c4ef78a0be 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -29,7 +29,7 @@ export const example = mysqlTable( }, (example) => ({ nameIndex: uniqueIndex("name_idx").on(example.name), - }), + }) ); export const users = mysqlTable("users", { @@ -63,7 +63,7 @@ export const accounts = mysqlTable( }, (account) => ({ compoundKey: primaryKey(account.provider, account.providerAccountId), - }), + }) ); export const accountsRelations = relations(accounts, ({ one }) => ({ @@ -89,5 +89,5 @@ export const verificationTokens = mysqlTable( }, (vt) => ({ compoundKey: primaryKey(vt.identifier, vt.token), - }), + }) ); diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index dd37019e26..85218c6b1a 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -27,5 +27,5 @@ export const example = mysqlTable( }, (example) => ({ nameIndex: uniqueIndex("name_idx").on(example.name), - }), + }) ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afa6949d99..4165b75d3e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,6 +67,12 @@ importers: cli: dependencies: + '@clack/core': + specifier: ^0.3.2 + version: 0.3.2 + '@clack/prompts': + specifier: ^0.6.3 + version: 0.6.3 '@ianvs/prettier-plugin-sort-imports': specifier: ^3.7.2 version: 3.7.2(prettier@2.8.8) @@ -1194,6 +1200,23 @@ packages: prettier: 2.8.8 dev: false + /@clack/core@0.3.2: + resolution: {integrity: sha512-FZnsNynwGDIDktx6PEZK1EuCkFpY4ldEX6VYvfl0dqeoLPb9Jpw1xoUXaVcGR8ExmYNm1w2vdGdJkEUYD/2pqg==} + dependencies: + picocolors: 1.0.0 + sisteransi: 1.0.5 + dev: false + + /@clack/prompts@0.6.3: + resolution: {integrity: sha512-AM+kFmAHawpUQv2q9+mcB6jLKxXGjgu/r2EQjEwujgpCdzrST6BJqYw00GRn56/L/Izw5U7ImoLmy00X/r80Pw==} + dependencies: + '@clack/core': 0.3.2 + picocolors: 1.0.0 + sisteransi: 1.0.5 + dev: false + bundledDependencies: + - is-unicode-supported + /@docsearch/css@3.3.4: resolution: {integrity: sha512-vDwCDoVXDgopw/hvr0zEADew2wWaGP8Qq0Bxhgii1Ewz2t4fQeyJwIRN/mWADeLFYPVkpz8TpEbxya/i6Tm0WA==} dev: false diff --git a/www/src/components/docs/companyList.tsx b/www/src/components/docs/companyList.tsx index cdd0aab8c9..e2136d1483 100644 --- a/www/src/components/docs/companyList.tsx +++ b/www/src/components/docs/companyList.tsx @@ -30,6 +30,11 @@ const companies: Company[] = [ linkName: "civitai.com", link: "https://civitai.com", }, + { + name: "GreatFrontEnd", + linkName: "greatfrontend.com", + link: "https://www.greatfrontend.com", + }, ]; export default function CompanyList({ diff --git a/www/src/components/navigation/githubIcon.astro b/www/src/components/navigation/githubIcon.astro index e20fc9896d..bd62800460 100644 --- a/www/src/components/navigation/githubIcon.astro +++ b/www/src/components/navigation/githubIcon.astro @@ -22,7 +22,7 @@ const isRtl = getIsRtlFromUrl(pathname);
- For more information about how `createEnv` internally works, check out the [T3 + For more information about how `createEnv` works internally, check out the [T3 Env](https://env.t3.gg/docs/introduction) docs @@ -123,3 +123,33 @@ export const env = createEnv({ ```bash TWITTER_API_TOKEN= ``` + +## Type Coercion + +All variables you add to `.env` will be imported as strings, even if their value is intended to represent a different type. If you want to use your environment variables as a different type at runtime, you can use Zod's `coerce` to convert the string to the type you want. It will throw if the coercion fails. + +Add the variables to your `.env`: + +``` +SOME_NUMBER=123 +SOME_BOOLEAN=true +``` + +Then, validate them in `env.mjs`: + +```ts +import { createEnv } from "@t3-oss/env-nextjs"; +import { z } from "zod"; + +export const env = createEnv({ + server: { + SOME_NUMBER: z.coerce.number(), + SOME_BOOLEAN: z.coerce.boolean(), + }, + // ... + runtimeEnv: { + SOME_NUMBER: process.env.SOME_NUMBER, + SOME_BOOLEAN: process.env.SOME_BOOLEAN, + }, +}); +``` diff --git a/www/src/pages/zh-hans/t3-collection.mdx b/www/src/pages/zh-hans/t3-collection.mdx index a0af368afe..4736058f1b 100644 --- a/www/src/pages/zh-hans/t3-collection.mdx +++ b/www/src/pages/zh-hans/t3-collection.mdx @@ -8,6 +8,7 @@ isMdx: true import OpenSourceAppList from "../../components/docs/openSourceAppList.tsx"; import CompanyList from "../../components/docs/companyList.tsx"; +import Callout from "../../components/docs/callout.tsx"; 使用 T3 stack 创建了一个项目并想要分享?将它添加到这个列表里吧。 @@ -21,4 +22,4 @@ import CompanyList from "../../components/docs/companyList.tsx"; -_用 T3 stack 构建了很酷的项目?开一个 [PR](https://github.com/t3-oss/create-t3-app/tree/next/www/src/components/docs/openSourceAppList.tsx) 将它加进来吧!_ +用 T3 stack 构建了很酷的项目?开一个 [PR](https://github.com/t3-oss/create-t3-app/tree/next/www/src/components/docs/openSourceAppList.tsx) 将它加进来吧! From c25626976d0acbaba67946d0dc4c6bcd583d80ec Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:31:43 +0200 Subject: [PATCH 14/71] format --- cli/.prettierrc.cjs | 11 ----------- cli/src/cli/index.ts | 7 ++++--- cli/src/helpers/installDependencies.ts | 7 ++++--- cli/src/installers/drizzle.ts | 3 ++- cli/src/installers/index.ts | 2 +- cli/src/installers/nextAuth.ts | 3 ++- cli/src/utils/parseNameAndPath.ts | 1 - cli/template/base/src/pages/index.tsx | 1 + .../extras/src/pages/index/with-auth-trpc.tsx | 3 ++- cli/template/extras/src/pages/index/with-trpc.tsx | 3 ++- .../server/api/routers/example/with-auth-drizzle.ts | 3 ++- .../src/server/api/routers/example/with-drizzle.ts | 1 + cli/template/extras/src/server/api/trpc/with-db.ts | 3 ++- cli/template/extras/src/server/auth/with-drizzle.ts | 3 ++- .../extras/src/server/db/drizzle-schema-auth.ts | 6 +++--- cli/template/extras/src/server/db/index-drizzle.ts | 3 ++- 16 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 cli/.prettierrc.cjs diff --git a/cli/.prettierrc.cjs b/cli/.prettierrc.cjs deleted file mode 100644 index 773d237852..0000000000 --- a/cli/.prettierrc.cjs +++ /dev/null @@ -1,11 +0,0 @@ -const baseConfig = require("../.prettierrc.cjs"); - -/** @type {import('prettier').Config} */ -const config = { - ...baseConfig, - plugins: [...baseConfig.plugins, "prettier-plugin-tailwindcss"], - tailwindConfig: "./template/extras/config/tailwind.config.ts", - trailingComma: "es5", -}; - -module.exports = config; diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index d9d0e1e9d3..53a3308b2d 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -1,4 +1,8 @@ import * as p from "@clack/prompts"; +import chalk from "chalk"; +import { Command } from "commander"; +import inquirer from "inquirer"; + import { CREATE_T3_APP, DEFAULT_APP_NAME } from "~/consts.js"; // import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; import { type AvailablePackages } from "~/installers/index.js"; @@ -9,9 +13,6 @@ import { IsTTYError } from "~/utils/isTTYError.js"; import { logger } from "~/utils/logger.js"; import { validateAppName } from "~/utils/validateAppName.js"; import { validateImportAlias } from "~/utils/validateImportAlias.js"; -import chalk from "chalk"; -import { Command } from "commander"; -import inquirer from "inquirer"; interface CliFlags { noGit: boolean; diff --git a/cli/src/helpers/installDependencies.ts b/cli/src/helpers/installDependencies.ts index bee4ab514e..9586cca08c 100644 --- a/cli/src/helpers/installDependencies.ts +++ b/cli/src/helpers/installDependencies.ts @@ -1,11 +1,12 @@ +import chalk from "chalk"; +import { execa } from "execa"; +import ora, { type Ora } from "ora"; + import { getUserPkgManager, type PackageManager, } from "~/utils/getUserPkgManager.js"; import { logger } from "~/utils/logger.js"; -import chalk from "chalk"; -import { execa } from "execa"; -import ora, { type Ora } from "ora"; interface Options { projectDir: string; diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 4e43983a03..d1f342937d 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -1,6 +1,7 @@ -import fs from "fs-extra"; import path from "path"; +import fs from "fs-extra"; import { type PackageJson } from "type-fest"; + import { PKG_ROOT } from "~/consts.js"; import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index b104bb1b01..6e5876bc2c 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -1,10 +1,10 @@ -import { drizzleInstaller } from "./drizzle.js"; import { envVariablesInstaller } from "~/installers/envVars.js"; import { nextAuthInstaller } from "~/installers/nextAuth.js"; import { prismaInstaller } from "~/installers/prisma.js"; import { tailwindInstaller } from "~/installers/tailwind.js"; import { trpcInstaller } from "~/installers/trpc.js"; import { type PackageManager } from "~/utils/getUserPkgManager.js"; +import { drizzleInstaller } from "./drizzle.js"; // Turning this into a const allows the list to be iterated over for programatically creating prompt options // Should increase extensability in the future diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index cab2965e72..6845a98fad 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -1,9 +1,10 @@ import path from "path"; +import fs from "fs-extra"; + import { PKG_ROOT } from "~/consts.js"; import { type AvailableDependencies } from "~/installers/dependencyVersionMap.js"; import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; -import fs from "fs-extra"; export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; diff --git a/cli/src/utils/parseNameAndPath.ts b/cli/src/utils/parseNameAndPath.ts index 7c1027b616..92dd20108d 100644 --- a/cli/src/utils/parseNameAndPath.ts +++ b/cli/src/utils/parseNameAndPath.ts @@ -1,4 +1,3 @@ -import { removeTrailingSlash } from "./removeTrailingSlash.js"; import pathModule from "path"; import { removeTrailingSlash } from "./removeTrailingSlash.js"; diff --git a/cli/template/base/src/pages/index.tsx b/cli/template/base/src/pages/index.tsx index 39e4255537..23c59c5678 100644 --- a/cli/template/base/src/pages/index.tsx +++ b/cli/template/base/src/pages/index.tsx @@ -1,5 +1,6 @@ import Head from "next/head"; import Link from "next/link"; + import styles from "./index.module.css"; export default function Home() { diff --git a/cli/template/extras/src/pages/index/with-auth-trpc.tsx b/cli/template/extras/src/pages/index/with-auth-trpc.tsx index a587f8d29f..a1f4dacbd8 100644 --- a/cli/template/extras/src/pages/index/with-auth-trpc.tsx +++ b/cli/template/extras/src/pages/index/with-auth-trpc.tsx @@ -1,7 +1,8 @@ -import { api } from "~/utils/api"; import { signIn, signOut, useSession } from "next-auth/react"; import Head from "next/head"; import Link from "next/link"; + +import { api } from "~/utils/api"; import styles from "./index.module.css"; export default function Home() { diff --git a/cli/template/extras/src/pages/index/with-trpc.tsx b/cli/template/extras/src/pages/index/with-trpc.tsx index e2e760b8d9..9b30a9b7bd 100644 --- a/cli/template/extras/src/pages/index/with-trpc.tsx +++ b/cli/template/extras/src/pages/index/with-trpc.tsx @@ -1,6 +1,7 @@ -import { api } from "~/utils/api"; import Head from "next/head"; import Link from "next/link"; + +import { api } from "~/utils/api"; import styles from "./index.module.css"; export default function Home() { diff --git a/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts b/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts index 42e3411c55..55a3189509 100644 --- a/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts +++ b/cli/template/extras/src/server/api/routers/example/with-auth-drizzle.ts @@ -1,8 +1,9 @@ import { z } from "zod"; + import { createTRPCRouter, - publicProcedure, protectedProcedure, + publicProcedure, } from "~/server/api/trpc"; export const exampleRouter = createTRPCRouter({ diff --git a/cli/template/extras/src/server/api/routers/example/with-drizzle.ts b/cli/template/extras/src/server/api/routers/example/with-drizzle.ts index 7e58cd36da..15f90c76b6 100644 --- a/cli/template/extras/src/server/api/routers/example/with-drizzle.ts +++ b/cli/template/extras/src/server/api/routers/example/with-drizzle.ts @@ -1,4 +1,5 @@ import { z } from "zod"; + import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; export const exampleRouter = createTRPCRouter({ diff --git a/cli/template/extras/src/server/api/trpc/with-db.ts b/cli/template/extras/src/server/api/trpc/with-db.ts index 5d92386154..dc3b40b241 100644 --- a/cli/template/extras/src/server/api/trpc/with-db.ts +++ b/cli/template/extras/src/server/api/trpc/with-db.ts @@ -8,10 +8,11 @@ */ import { initTRPC } from "@trpc/server"; import { type CreateNextContextOptions } from "@trpc/server/adapters/next"; -import { db } from "~/server/db"; import superjson from "superjson"; import { ZodError } from "zod"; +import { db } from "~/server/db"; + /** * 1. CONTEXT * diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 1f018f8eb9..76c4f2b48c 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -2,11 +2,12 @@ import { and, eq } from "drizzle-orm"; import { type GetServerSidePropsContext } from "next"; import { getServerSession, - type NextAuthOptions, type DefaultSession, + type NextAuthOptions, } from "next-auth"; import { type Adapter } from "next-auth/adapters"; import DiscordProvider from "next-auth/providers/discord"; + import { env } from "~/env.mjs"; import { db } from "~/server/db"; import * as schema from "~/server/db/schema"; diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index c4ef78a0be..28bed32b73 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -1,13 +1,13 @@ import { relations } from "drizzle-orm"; import { int, - timestamp, mysqlTableCreator, - varchar, primaryKey, serial, - uniqueIndex, text, + timestamp, + uniqueIndex, + varchar, } from "drizzle-orm/mysql-core"; import { type AdapterAccount } from "next-auth/adapters"; diff --git a/cli/template/extras/src/server/db/index-drizzle.ts b/cli/template/extras/src/server/db/index-drizzle.ts index 1d684e71e3..0116d84704 100644 --- a/cli/template/extras/src/server/db/index-drizzle.ts +++ b/cli/template/extras/src/server/db/index-drizzle.ts @@ -1,7 +1,8 @@ -import * as schema from "./schema"; import { connect } from "@planetscale/database"; import { drizzle } from "drizzle-orm/planetscale-serverless"; + import { env } from "~/env.mjs"; +import * as schema from "./schema"; // create the connection const connection = connect({ From 076bf36996346477694fdb0047cd2d53059c96d3 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:34:57 +0200 Subject: [PATCH 15/71] lint --- .eslintrc.cjs | 3 +++ cli/src/installers/envVars.ts | 3 ++- cli/src/installers/index.ts | 2 +- cli/src/installers/nextAuth.ts | 3 ++- cli/src/installers/trpc.ts | 3 ++- cli/template/extras/src/server/auth/with-drizzle.ts | 6 +++--- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a050858b18..c6d2a93195 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -46,6 +46,9 @@ const config = { // These lint rules don't make sense for us but are enabled in the preset configs "@typescript-eslint/no-confusing-void-expression": "off", "@typescript-eslint/restrict-template-expressions": "off", + + // This rule doesn't seem to be working properly + "@typescript-eslint/prefer-nullish-coalescing": "off", }, }; diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index b936e32a08..13fd74a96a 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -7,7 +7,8 @@ import { type Installer } from "~/installers/index.js"; export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = packages?.drizzle.inUse; + const usingDrizzle = + packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; const envContent = getEnvContent(!!usingAuth, !!usingPrisma, !!usingDrizzle); diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 6e5876bc2c..2580a137a6 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -4,7 +4,7 @@ import { prismaInstaller } from "~/installers/prisma.js"; import { tailwindInstaller } from "~/installers/tailwind.js"; import { trpcInstaller } from "~/installers/trpc.js"; import { type PackageManager } from "~/utils/getUserPkgManager.js"; -import { drizzleInstaller } from "./drizzle.js"; +import { getDrizzleInstaller } from "./drizzle.js"; // Turning this into a const allows the list to be iterated over for programatically creating prompt options // Should increase extensability in the future diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 6845a98fad..051d5cdaac 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -8,7 +8,8 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = packages?.drizzle.inUse; + const usingDrizzle = + packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; const deps: AvailableDependencies[] = ["next-auth"]; if (usingPrisma) deps.push("@next-auth/prisma-adapter"); diff --git a/cli/src/installers/trpc.ts b/cli/src/installers/trpc.ts index 4d1cd24141..4068945c1d 100644 --- a/cli/src/installers/trpc.ts +++ b/cli/src/installers/trpc.ts @@ -21,7 +21,8 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = packages?.drizzle.inUse; + const usingDrizzle = + packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; const usingDb = usingPrisma || usingDrizzle; const extrasDir = path.join(PKG_ROOT, "template/extras"); diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 76c4f2b48c..3ae74baded 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -99,7 +99,7 @@ export function DrizzleAdapter(): Adapter { .from(users) .where(eq(users.id, id)) .then((res) => res[0]); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return user!; }, getUser: async (data) => { @@ -117,7 +117,7 @@ export function DrizzleAdapter(): Adapter { .select() .from(sessions) .where(eq(sessions.sessionToken, data.sessionToken)); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return session[0]!; }, getSessionAndUser: async (data) => { @@ -140,7 +140,7 @@ export function DrizzleAdapter(): Adapter { await db.update(users).set(data).where(eq(users.id, data.id)); const user = await db.select().from(users).where(eq(users.id, data.id)); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return user[0]!; }, updateSession: async (data) => { From af5257f4b2fc98faf817d5fa9f6b6e1829e282c9 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:40:11 +0200 Subject: [PATCH 16/71] fix --- cli/src/cli/index.ts | 28 +++------- cli/src/helpers/logNextSteps.ts | 2 +- cli/src/installers/dependencyVersionMap.ts | 1 - cli/src/installers/drizzle.ts | 61 +--------------------- cli/src/installers/envVars.ts | 3 +- cli/src/installers/index.ts | 15 ++---- cli/src/installers/nextAuth.ts | 3 +- cli/src/installers/trpc.ts | 3 +- 8 files changed, 17 insertions(+), 99 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 53a3308b2d..c001fe7c26 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -29,7 +29,7 @@ interface CliFlags { /** @internal Used in CI. */ prisma: boolean; /** @internal Used in CI. */ - drizzle: boolean | "pscale" | "pg"; + drizzle: boolean; /** @internal Used in CI. */ nextAuth: boolean; } @@ -108,19 +108,9 @@ export const runCli = async (): Promise => { ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( - "--drizzle [string]", - "Experimental: What SQL Dialect to use if using Drizzle. Must be used in conjunction with `--CI`.", - (value) => { - if (!value || value === "false") { - return false; - } - if (["pg", "pscale"].includes(value)) { - return value; - } - throw new Error( - `Invalid value for --drizzle. Expected: 'none', 'pg' or 'pscale', got '${value}'` - ); - } + "--drizzle [boolean]", + "Experimental: Boolean value if we should install Drizzle. Must be used in conjunction with `--CI`.", + (value) => !!value && value !== "false" ) /** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */ .option( @@ -170,10 +160,7 @@ export const runCli = async (): Promise => { if (cliResults.flags.trpc) cliResults.packages.push("trpc"); if (cliResults.flags.tailwind) cliResults.packages.push("tailwind"); if (cliResults.flags.prisma) cliResults.packages.push("prisma"); - if (cliResults.flags.drizzle === "pg") - cliResults.packages.push("drizzle-pg"); - if (cliResults.flags.drizzle === "pscale") - cliResults.packages.push("drizzle-pscale"); + if (cliResults.flags.drizzle) cliResults.packages.push("drizzle"); if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); if (cliResults.flags.prisma && cliResults.flags.drizzle) { @@ -182,7 +169,7 @@ export const runCli = async (): Promise => { ); cliResults.flags.drizzle = false; cliResults.packages = cliResults.packages.filter( - (pkg) => pkg !== "drizzle-pg" && pkg !== "drizzle-pscale" + (pkg) => pkg !== "drizzle" ); } @@ -305,8 +292,7 @@ export const runCli = async (): Promise => { if (project.trpc) packages.push("trpc"); if (project.authentication === "next-auth") packages.push("nextAuth"); if (project.database === "prisma") packages.push("prisma"); - if (project.database === "drizzle-pscale") packages.push("drizzle-pscale"); - if (project.database === "drizzle-pg") packages.push("drizzle-pg"); + if (project.database === "drizzle") packages.push("drizzle"); return { appName: project.name ?? cliResults.appName, diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index c70632b63d..17391d65c1 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -27,7 +27,7 @@ export const logNextSteps = async ({ } } - const drizzleInUse = packages?.["drizzle-pg"] || packages?.["drizzle-pscale"]; + const drizzleInUse = packages?.["drizzle"]; if (packages?.prisma.inUse || drizzleInUse) { logger.info(` ${pkgManager === "npm" ? "npx" : pkgManager} db:push`); } diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 49b0e2fad0..b7703439f1 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -15,7 +15,6 @@ export const dependencyVersionMap = { "drizzle-orm": "^0.26.3", "drizzle-kit": "^0.18.1", dotenv: "^16.1.4", - // REVIEW: Is it fine including pscale by default? "@planetscale/database": "^1.7.0", // TailwindCSS diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index d1f342937d..1e0031e2ae 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -6,20 +6,7 @@ import { PKG_ROOT } from "~/consts.js"; import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; -export const getDrizzleInstaller = ( - dialect: "sqlite" | "pscale" -): Installer => { - switch (dialect) { - case "sqlite": - return sqliteDrizzleInstaller; - case "pscale": - return pscaleDrizzleInstaller; - default: - throw new Error(`Invalid dialect: ${dialect}`); - } -}; - -const pscaleDrizzleInstaller: Installer = ({ projectDir, packages }) => { +export const drizzleInstaller: Installer = ({ projectDir, packages }) => { addPackageDependency({ projectDir, dependencies: ["drizzle-kit", "dotenv"], @@ -64,49 +51,3 @@ const pscaleDrizzleInstaller: Installer = ({ projectDir, packages }) => { spaces: 2, }); }; - -const sqliteDrizzleInstaller: Installer = ({ projectDir, packages }) => { - addPackageDependency({ - projectDir, - dependencies: ["drizzle-kit", "dotenv", "@types/pg"], - devMode: true, - }); - addPackageDependency({ - projectDir, - dependencies: ["drizzle-orm", "pg"], - devMode: false, - }); - - const extrasDir = path.join(PKG_ROOT, "template/extras"); - - const configFile = path.join(extrasDir, "config/drizzle.config.ts"); - const configDest = path.join(projectDir, "drizzle.config.ts"); - - const schemaSrc = path.join( - extrasDir, - "src/server/db", - packages?.nextAuth.inUse - ? "drizzle-schema-auth.ts" - : "drizzle-schema-base.ts" - ); - const schemaDest = path.join(projectDir, "src/server/db/schema.ts"); - - const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); - const clientDest = path.join(projectDir, "src/server/db/index.ts"); - - // add db:push script to package.json - const packageJsonPath = path.join(projectDir, "package.json"); - - const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; - packageJsonContent.scripts = { - ...packageJsonContent.scripts, - "db:push": "drizzle-kit push:sqlite", - }; - - fs.copySync(configFile, configDest); - fs.copySync(schemaSrc, schemaDest); - fs.copySync(clientSrc, clientDest); - fs.writeJSONSync(packageJsonPath, packageJsonContent, { - spaces: 2, - }); -}; diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index 13fd74a96a..b936e32a08 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -7,8 +7,7 @@ import { type Installer } from "~/installers/index.js"; export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = - packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; + const usingDrizzle = packages?.drizzle.inUse; const envContent = getEnvContent(!!usingAuth, !!usingPrisma, !!usingDrizzle); diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 2580a137a6..0126111596 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -4,15 +4,14 @@ import { prismaInstaller } from "~/installers/prisma.js"; import { tailwindInstaller } from "~/installers/tailwind.js"; import { trpcInstaller } from "~/installers/trpc.js"; import { type PackageManager } from "~/utils/getUserPkgManager.js"; -import { getDrizzleInstaller } from "./drizzle.js"; +import { drizzleInstaller } from "./drizzle.js"; // Turning this into a const allows the list to be iterated over for programatically creating prompt options // Should increase extensability in the future export const availablePackages = [ "nextAuth", "prisma", - "drizzle-pscale", - "drizzle-pg", + "drizzle", "tailwind", "trpc", "envVariables", @@ -47,13 +46,9 @@ export const buildPkgInstallerMap = ( inUse: packages.includes("prisma"), installer: prismaInstaller, }, - "drizzle-pg": { - inUse: packages.includes("drizzle-pg"), - installer: getDrizzleInstaller("pg"), - }, - "drizzle-pscale": { - inUse: packages.includes("drizzle-pscale"), - installer: getDrizzleInstaller("pscale"), + drizzle: { + inUse: packages.includes("drizzle"), + installer: drizzleInstaller, }, tailwind: { inUse: packages.includes("tailwind"), diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 051d5cdaac..6845a98fad 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -8,8 +8,7 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = - packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; + const usingDrizzle = packages?.drizzle.inUse; const deps: AvailableDependencies[] = ["next-auth"]; if (usingPrisma) deps.push("@next-auth/prisma-adapter"); diff --git a/cli/src/installers/trpc.ts b/cli/src/installers/trpc.ts index 4068945c1d..4d1cd24141 100644 --- a/cli/src/installers/trpc.ts +++ b/cli/src/installers/trpc.ts @@ -21,8 +21,7 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => { const usingAuth = packages?.nextAuth.inUse; const usingPrisma = packages?.prisma.inUse; - const usingDrizzle = - packages?.["drizzle-pg"].inUse || packages?.["drizzle-pscale"].inUse; + const usingDrizzle = packages?.drizzle.inUse; const usingDb = usingPrisma || usingDrizzle; const extrasDir = path.join(PKG_ROOT, "template/extras"); From 0fe566484612e3827689855734aa6bc1483bc12d Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:48:48 +0200 Subject: [PATCH 17/71] fix more --- cli/package.json | 1 + cli/src/installers/dependencyVersionMap.ts | 1 + cli/src/installers/nextAuth.ts | 2 +- cli/template/extras/config/drizzle.config.ts | 15 +- .../extras/src/server/auth/with-drizzle.ts | 168 +----------- .../src/server/db/drizzle-schema-auth.ts | 37 ++- .../src/server/db/drizzle-schema-base.ts | 2 +- .../extras/src/server/db/index-drizzle.ts | 14 +- pnpm-lock.yaml | 244 +++++++++++++++++- 9 files changed, 292 insertions(+), 192 deletions(-) diff --git a/cli/package.json b/cli/package.json index c73004d520..eb844f4a9b 100644 --- a/cli/package.json +++ b/cli/package.json @@ -67,6 +67,7 @@ "@types/inquirer": "^9.0.3", "@types/node": "^18.16.0", "drizzle-orm": "^0.26.5", + "drizzle-kit": "^0.19.12", "next": "^13.4.1", "next-auth": "^4.22.1", "prettier": "^3.0.0", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index b7703439f1..2e6746ad05 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -6,6 +6,7 @@ export const dependencyVersionMap = { // NextAuth.js "next-auth": "^4.22.4", "@next-auth/prisma-adapter": "^1.0.7", + "@next-auth/drizzle-adapter": "^0.2.1", // Prisma prisma: "^5.1.1", diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 6845a98fad..ab2e36282a 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -13,7 +13,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const deps: AvailableDependencies[] = ["next-auth"]; if (usingPrisma) deps.push("@next-auth/prisma-adapter"); // This adapter is not yet available on npm so we have our own inhoused - // if (usingDrizzle) deps.push("@next-auth/drizzle-adapter"); + if (usingDrizzle) deps.push("@next-auth/drizzle-adapter"); addPackageDependency({ projectDir, diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index 4226a1fd38..e82e07e1d2 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,9 +1,18 @@ import * as dotenv from "dotenv"; import { type Config } from "drizzle-kit"; -dotenv.config(); +dotenv.config({ + path: "../../.env", +}); + +if (!process.env.DATABASE_URL) { + throw new Error("DATABASE_URL is not set"); +} export default { - schema: "./src/server/db/schema.ts", - connectionString: process.env.DATABASE_URL, + schema: "./schema", + driver: "mysql2", + dbCredentials: { + connectionString: process.env.DATABASE_URL, + }, } satisfies Config; diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 3ae74baded..8a9becf451 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -1,3 +1,4 @@ +import { DrizzleAdapter } from "@next-auth/drizzle-adapter"; import { and, eq } from "drizzle-orm"; import { type GetServerSidePropsContext } from "next"; import { @@ -5,12 +6,11 @@ import { type DefaultSession, type NextAuthOptions, } from "next-auth"; -import { type Adapter } from "next-auth/adapters"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env.mjs"; import { db } from "~/server/db"; -import * as schema from "~/server/db/schema"; +import { mysqlTable } from "~/server/db/schema"; /** * Module augmentation for `next-auth` types. Allows us to add custom properties to the `session` @@ -48,7 +48,7 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: DrizzleAdapter(), + adapter: DrizzleAdapter(db, mysqlTable), providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, @@ -77,165 +77,3 @@ export const getServerAuthSession = (ctx: { }) => { return getServerSession(ctx.req, ctx.res, authOptions); }; - -/** - * Adapter for Drizzle ORM. This is not yet available in NextAuth directly, so we inhouse our own. - * When the official one is out, we will switch to that. - * - * @see - * https://github.com/nextauthjs/next-auth/pull/7165/files#diff-142e7d6584eed63a73316fbc041fb93a0564a1cbb0da71200b92628ca66024b5 - */ - -export function DrizzleAdapter(): Adapter { - const { users, sessions, accounts, verificationTokens } = schema; - return { - createUser: async (data) => { - const id = crypto.randomUUID(); - - await db.insert(users).values({ ...data, id }); - - const user = await db - .select() - .from(users) - .where(eq(users.id, id)) - .then((res) => res[0]); - - return user!; - }, - getUser: async (data) => { - const user = await db.select().from(users).where(eq(users.id, data)); - return user[0] ?? null; - }, - getUserByEmail: async (data) => { - const user = await db.select().from(users).where(eq(users.email, data)); - return user[0] ?? null; - }, - createSession: async (data) => { - await db.insert(sessions).values(data); - - const session = await db - .select() - .from(sessions) - .where(eq(sessions.sessionToken, data.sessionToken)); - - return session[0]!; - }, - getSessionAndUser: async (data) => { - const sessionAndUser = await db - .select({ - session: sessions, - user: users, - }) - .from(sessions) - .where(eq(sessions.sessionToken, data)) - .innerJoin(users, eq(users.id, sessions.userId)); - - return sessionAndUser[0] ?? null; - }, - updateUser: async (data) => { - if (!data.id) { - throw new Error("No user id."); - } - - await db.update(users).set(data).where(eq(users.id, data.id)); - - const user = await db.select().from(users).where(eq(users.id, data.id)); - - return user[0]!; - }, - updateSession: async (data) => { - await db - .update(sessions) - .set(data) - .where(eq(sessions.sessionToken, data.sessionToken)); - - return db - .select() - .from(sessions) - .where(eq(sessions.sessionToken, data.sessionToken)) - .then((res) => res[0]); - }, - linkAccount: async (rawAccount) => { - await db - .insert(accounts) - .values(rawAccount) - .then((res) => res.rows[0]); - }, - getUserByAccount: async (account) => { - const dbAccount = await db - .select() - .from(accounts) - .where( - and( - eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider) - ) - ) - .leftJoin(users, eq(accounts.userId, users.id)) - .then((res) => res[0]); - - return dbAccount?.users ?? null; - }, - deleteSession: async (sessionToken) => { - await db.delete(sessions).where(eq(sessions.sessionToken, sessionToken)); - }, - createVerificationToken: async (token) => { - await db.insert(verificationTokens).values(token); - - return db - .select() - .from(verificationTokens) - .where(eq(verificationTokens.identifier, token.identifier)) - .then((res) => res[0]); - }, - useVerificationToken: async (token) => { - try { - const deletedToken = - (await db - .select() - .from(verificationTokens) - .where( - and( - eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token) - ) - ) - .then((res) => res[0])) ?? null; - - await db - .delete(verificationTokens) - .where( - and( - eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token) - ) - ); - - return deletedToken; - } catch (err) { - throw new Error("No verification token found."); - } - }, - deleteUser: async (id) => { - await Promise.all([ - db.delete(users).where(eq(users.id, id)), - db.delete(sessions).where(eq(sessions.userId, id)), - db.delete(accounts).where(eq(accounts.userId, id)), - ]); - - return null; - }, - unlinkAccount: async (account) => { - await db - .delete(accounts) - .where( - and( - eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider) - ) - ); - - return undefined; - }, - }; -} diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index 28bed32b73..884e0075e4 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -1,5 +1,6 @@ -import { relations } from "drizzle-orm"; +import { relations, sql } from "drizzle-orm"; import { + index, int, mysqlTableCreator, primaryKey, @@ -17,7 +18,7 @@ import { type AdapterAccount } from "next-auth/adapters"; * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ -const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); +export const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); export const example = mysqlTable( "example", @@ -36,7 +37,10 @@ export const users = mysqlTable("users", { id: varchar("id", { length: 255 }).notNull().primaryKey(), name: varchar("name", { length: 255 }), email: varchar("email", { length: 255 }).notNull(), - emailVerified: timestamp("emailVerified", { mode: "date" }), + emailVerified: timestamp("emailVerified", { + mode: "date", + fsp: 3, + }).default(sql`CURRENT_TIMESTAMP(3)`), image: varchar("image", { length: 255 }), }); @@ -53,16 +57,17 @@ export const accounts = mysqlTable( .notNull(), provider: varchar("provider", { length: 255 }).notNull(), providerAccountId: varchar("providerAccountId", { length: 255 }).notNull(), - refresh_token: text("refresh_token"), - access_token: text("access_token"), + refresh_token: varchar("refresh_token", { length: 255 }), + access_token: varchar("access_token", { length: 255 }), expires_at: int("expires_at"), token_type: varchar("token_type", { length: 255 }), scope: varchar("scope", { length: 255 }), - id_token: text("id_token"), + id_token: varchar("id_token", { length: 255 }), session_state: varchar("session_state", { length: 255 }), }, (account) => ({ compoundKey: primaryKey(account.provider, account.providerAccountId), + userIdIdx: index("userId_idx").on(account.userId), }) ); @@ -70,14 +75,22 @@ export const accountsRelations = relations(accounts, ({ one }) => ({ user: one(users, { fields: [accounts.userId], references: [users.id] }), })); -export const sessions = mysqlTable("sessions", { - sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(), - userId: varchar("userId", { length: 255 }).notNull(), - expires: timestamp("expires", { mode: "date" }).notNull(), -}); +export const sessions = mysqlTable( + "sessions", + { + sessionToken: varchar("sessionToken", { length: 255 }) + .notNull() + .primaryKey(), + userId: varchar("userId", { length: 255 }).notNull(), + expires: timestamp("expires", { mode: "date" }).notNull(), + }, + (session) => ({ + userIdIdx: index("userId_idx").on(session.userId), + }) +); export const sessionsRelations = relations(sessions, ({ one }) => ({ - user: one(users, { fields: [sessions.userId], references: [users.id] }), + user: one(users), })); export const verificationTokens = mysqlTable( diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index 85218c6b1a..b64ea87eac 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -15,7 +15,7 @@ import { * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ -const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); +export const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); export const example = mysqlTable( "example", diff --git a/cli/template/extras/src/server/db/index-drizzle.ts b/cli/template/extras/src/server/db/index-drizzle.ts index 0116d84704..2a0c8e8f4d 100644 --- a/cli/template/extras/src/server/db/index-drizzle.ts +++ b/cli/template/extras/src/server/db/index-drizzle.ts @@ -1,12 +1,12 @@ -import { connect } from "@planetscale/database"; +import { Client } from "@planetscale/database"; import { drizzle } from "drizzle-orm/planetscale-serverless"; import { env } from "~/env.mjs"; import * as schema from "./schema"; -// create the connection -const connection = connect({ - url: env.DATABASE_URL, -}); - -export const db = drizzle(connection, { schema }); +export const db = drizzle( + new Client({ + url: env.DATABASE_URL, + }).connection(), + { schema } +); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27d09d24ce..e39d687238 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -134,6 +134,9 @@ importers: '@types/node': specifier: ^18.16.0 version: 18.16.1 + drizzle-kit: + specifier: ^0.19.12 + version: 0.19.12 drizzle-orm: specifier: ^0.26.5 version: 0.26.5(@planetscale/database@1.7.0) @@ -1238,6 +1241,10 @@ packages: - '@algolia/client-search' dev: false + /@drizzle-team/studio@0.0.5: + resolution: {integrity: sha512-ps5qF0tMxWRVu+V5gvCRrQNqlY92aTnIKdq27gm9LZMSdaKYZt6AVvSK1dlUMzs6Rt0Jm80b+eWct6xShBKhIw==} + dev: true + /@emmetio/abbreviation@2.3.3: resolution: {integrity: sha512-mgv58UrU3rh4YgbE/TzgLQwJ3pFsHHhCLqY20aJq+9comytTXUDNGG/SMtSeMJdkpxgXSXunBGLD8Boka3JyVA==} dependencies: @@ -1251,6 +1258,20 @@ packages: /@emmetio/scanner@1.0.4: resolution: {integrity: sha512-IqRuJtQff7YHHBk4G8YZ45uB9BaAGcwQeVzgj/zj8/UdOhtQpEIupUhSk8dys6spFIWVZVeK20CzGEnqR5SbqA==} + /@esbuild-kit/core-utils@3.1.0: + resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} + dependencies: + esbuild: 0.17.12 + source-map-support: 0.5.21 + dev: true + + /@esbuild-kit/esm-loader@2.5.5: + resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==} + dependencies: + '@esbuild-kit/core-utils': 3.1.0 + get-tsconfig: 4.7.0 + dev: true + /@esbuild/android-arm64@0.17.12: resolution: {integrity: sha512-WQ9p5oiXXYJ33F2EkE3r0FRDFVpEdcDiwNX3u7Xaibxfx6vQE0Sb8ytrfQsA5WO6kDn6mDfKLh6KrPBjvkk7xA==} engines: {node: '>=12'} @@ -3760,6 +3781,12 @@ packages: balanced-match: 1.0.2 concat-map: 0.0.1 + /brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: true + /braces@3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} @@ -3784,7 +3811,6 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - dev: false /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} @@ -3868,6 +3894,11 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} + /camelcase@7.0.1: + resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==} + engines: {node: '>=14.16'} + dev: true + /camelize@1.0.1: resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} dev: false @@ -3968,6 +3999,17 @@ packages: resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} engines: {node: '>=10'} + /cli-color@2.0.3: + resolution: {integrity: sha512-OkoZnxyC4ERN3zLzZaY9Emb7f/MhBOIpePv0Ycok0fJYT+Ouo00UBEIwsVsr0yoow++n5YWlSUgST9GKhNHiRQ==} + engines: {node: '>=0.10'} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-iterator: 2.0.3 + memoizee: 0.4.15 + timers-ext: 0.1.7 + dev: true + /cli-cursor@3.1.0: resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} engines: {node: '>=8'} @@ -4076,6 +4118,11 @@ packages: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} + /commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + dev: true + /common-ancestor-path@1.0.1: resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} @@ -4167,6 +4214,13 @@ packages: stream-transform: 2.1.3 dev: false + /d@1.0.1: + resolution: {integrity: sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==} + dependencies: + es5-ext: 0.10.62 + type: 1.2.0 + dev: true + /damerau-levenshtein@1.0.8: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} dev: true @@ -4334,6 +4388,12 @@ packages: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} + /difflib@0.2.4: + resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} + dependencies: + heap: 0.2.7 + dev: true + /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -4360,6 +4420,33 @@ packages: engines: {node: '>=10'} dev: false + /dreamopt@0.8.0: + resolution: {integrity: sha512-vyJTp8+mC+G+5dfgsY+r3ckxlz+QMX40VjPQsZc5gxVAxLmi64TBoVkP54A/pRAXMXsbu2GMMBrZPxNv23waMg==} + engines: {node: '>=0.4.0'} + dependencies: + wordwrap: 1.0.0 + dev: true + + /drizzle-kit@0.19.12: + resolution: {integrity: sha512-rcsmh5gUIkvuD0WrbEc+aLpqY2q2J8ltynRcJiJo2l01hhsYvPnX0sgxWlFXlfAIa5ZXNw2nJZhYlslI6tG3MA==} + hasBin: true + dependencies: + '@drizzle-team/studio': 0.0.5 + '@esbuild-kit/esm-loader': 2.5.5 + camelcase: 7.0.1 + chalk: 5.2.0 + commander: 9.5.0 + esbuild: 0.18.15 + esbuild-register: 3.4.2(esbuild@0.18.15) + glob: 8.1.0 + hanji: 0.0.5 + json-diff: 0.9.0 + minimatch: 7.4.6 + zod: 3.21.4 + transitivePeerDependencies: + - supports-color + dev: true + /drizzle-orm@0.26.5(@planetscale/database@1.7.0): resolution: {integrity: sha512-ajjbOIoXqldWoWBn0RbVQCCT732R4Ad+gUjUrlmMpzWYwgnbG/qqPy84NhHntQ/MR//z3xfvT1Z2fD8uCAPX3g==} peerDependencies: @@ -4569,6 +4656,51 @@ packages: is-date-object: 1.0.5 is-symbol: 1.0.4 + /es5-ext@0.10.62: + resolution: {integrity: sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==} + engines: {node: '>=0.10'} + requiresBuild: true + dependencies: + es6-iterator: 2.0.3 + es6-symbol: 3.1.3 + next-tick: 1.1.0 + dev: true + + /es6-iterator@2.0.3: + resolution: {integrity: sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-symbol: 3.1.3 + dev: true + + /es6-symbol@3.1.3: + resolution: {integrity: sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==} + dependencies: + d: 1.0.1 + ext: 1.7.0 + dev: true + + /es6-weak-map@2.0.3: + resolution: {integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-iterator: 2.0.3 + es6-symbol: 3.1.3 + dev: true + + /esbuild-register@3.4.2(esbuild@0.18.15): + resolution: {integrity: sha512-kG/XyTDyz6+YDuyfB9ZoSIOOmgyFCH+xPRtsCa8W85HLRV5Csp+o3jWVbOSHgSLfyLc5DmP+KFDNwty4mEjC+Q==} + peerDependencies: + esbuild: '>=0.12 <1' + dependencies: + debug: 4.3.4 + esbuild: 0.18.15 + transitivePeerDependencies: + - supports-color + dev: true + /esbuild@0.17.12: resolution: {integrity: sha512-bX/zHl7Gn2CpQwcMtRogTTBf9l1nl+H6R8nUbjk+RuKqAE3+8FDulLA+pHvX7aA7Xe07Iwa+CWvy9I8Y2qqPKQ==} engines: {node: '>=12'} @@ -5043,6 +5175,13 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + /event-emitter@0.3.5: + resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + dev: true + /events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} @@ -5095,6 +5234,12 @@ packages: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} + /ext@1.7.0: + resolution: {integrity: sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==} + dependencies: + type: 2.7.2 + dev: true + /extend-shallow@2.0.1: resolution: {integrity: sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==} engines: {node: '>=0.10.0'} @@ -5425,6 +5570,17 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 + /glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + dev: true + /globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -5519,6 +5675,13 @@ packages: section-matter: 1.0.0 strip-bom-string: 1.0.0 + /hanji@0.0.5: + resolution: {integrity: sha512-Abxw1Lq+TnYiL4BueXqMau222fPSPMFtya8HdpWsz/xVAhifXou71mPh/kY2+08RgFcVccjG3uZHs6K5HAe3zw==} + dependencies: + lodash.throttle: 4.1.1 + sisteransi: 1.0.5 + dev: true + /hard-rejection@2.1.0: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} engines: {node: '>=6'} @@ -5691,6 +5854,10 @@ packages: property-information: 6.2.0 space-separated-tokens: 2.0.2 + /heap@0.2.7: + resolution: {integrity: sha512-2bsegYkkHO+h/9MGbn6KWcE45cHZgPANo5LXF7EvWdT0yT2EguSVO1nDgU5c8+ZOPwp2vMNa7YFsJhVcDR9Sdg==} + dev: true + /hex-rgb@4.3.0: resolution: {integrity: sha512-Ox1pJVrDCyGHMG9CFg1tmrRUMRPRsAWYc/PinY0XzJU4K7y7vjNoLKIQ7BR5UJMCxNN8EM1MNDmHWA/B3aZUuw==} engines: {node: '>=6'} @@ -5998,6 +6165,10 @@ packages: engines: {node: '>=0.10.0'} dev: false + /is-promise@2.2.2: + resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==} + dev: true + /is-reference@3.0.1: resolution: {integrity: sha512-baJJdQLiYaJdvFbJqXrcGv3WU3QCzBlUcI5QhbesIm6/xPsvmO+2CDoi/GMOFBQEQm+PXkwOPrp9KK5ozZsp2w==} dependencies: @@ -6160,6 +6331,15 @@ packages: resolution: {integrity: sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==} dev: false + /json-diff@0.9.0: + resolution: {integrity: sha512-cVnggDrVkAAA3OvFfHpFEhOnmcsUpleEKq4d4O8sQWWSH40MBrWstKigVB1kGrgLWzuom+7rRdaCsnBD6VyObQ==} + hasBin: true + dependencies: + cli-color: 2.0.3 + difflib: 0.2.4 + dreamopt: 0.8.0 + dev: true + /json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} dev: false @@ -6299,6 +6479,10 @@ packages: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} dev: false + /lodash.throttle@4.1.1: + resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} + dev: true + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: false @@ -6355,6 +6539,12 @@ packages: dependencies: yallist: 4.0.0 + /lru-queue@0.1.0: + resolution: {integrity: sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==} + dependencies: + es5-ext: 0.10.62 + dev: true + /lucide-react@0.216.0(react@18.2.0): resolution: {integrity: sha512-PGWXs6JXI/08rhfkmj/joji0MAKDCcms44j0LYILO4J36AWqKhgjjaZ6WECRSyZ9TQe5gOrAR0g38O8cKrQngw==} peerDependencies: @@ -6575,6 +6765,19 @@ packages: dependencies: '@types/mdast': 3.0.11 + /memoizee@0.4.15: + resolution: {integrity: sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==} + dependencies: + d: 1.0.1 + es5-ext: 0.10.62 + es6-weak-map: 2.0.3 + event-emitter: 0.3.5 + is-promise: 2.2.2 + lru-queue: 0.1.0 + next-tick: 1.1.0 + timers-ext: 0.1.7 + dev: true + /meow@6.1.1: resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} engines: {node: '>=8'} @@ -6962,6 +7165,20 @@ packages: dependencies: brace-expansion: 1.1.11 + /minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: true + + /minimatch@7.4.6: + resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} engines: {node: '>= 6'} @@ -7073,6 +7290,10 @@ packages: uuid: 8.3.2 dev: true + /next-tick@1.1.0: + resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} + dev: true + /next@13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-JBw2kAIyhKDpjhEWvNVoFeIzNp9xNxg8wrthDOtMctfn3EpqGCmW0FSviNyGgOSOSn6zDaX48pmvbdf6X2W9xA==} engines: {node: '>=16.8.0'} @@ -8559,12 +8780,10 @@ packages: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 - dev: false /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} - dev: false /source-map@0.7.4: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} @@ -8976,6 +9195,13 @@ packages: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: false + /timers-ext@0.1.7: + resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==} + dependencies: + es5-ext: 0.10.62 + next-tick: 1.1.0 + dev: true + /tiny-glob@0.2.9: resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} dependencies: @@ -9253,6 +9479,14 @@ packages: engines: {node: '>=14.16'} dev: true + /type@1.2.0: + resolution: {integrity: sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==} + dev: true + + /type@2.7.2: + resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==} + dev: true + /typed-array-length@1.0.4: resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} dependencies: @@ -9773,6 +10007,10 @@ packages: resolution: {integrity: sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==} engines: {node: '>=0.10.0'} + /wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} + dev: true + /wrap-ansi@6.2.0: resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} engines: {node: '>=8'} From 7fabeeabc1e697d7b05a2c619f8d95d577bb52e2 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:51:07 +0200 Subject: [PATCH 18/71] fixx --- cli/package.json | 2 +- cli/src/helpers/logNextSteps.ts | 2 +- cli/template/extras/src/server/auth/with-drizzle.ts | 1 - cli/template/extras/src/server/db/drizzle-schema-auth.ts | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cli/package.json b/cli/package.json index eb844f4a9b..b9d969569a 100644 --- a/cli/package.json +++ b/cli/package.json @@ -66,8 +66,8 @@ "@types/gradient-string": "^1.1.2", "@types/inquirer": "^9.0.3", "@types/node": "^18.16.0", - "drizzle-orm": "^0.26.5", "drizzle-kit": "^0.19.12", + "drizzle-orm": "^0.26.5", "next": "^13.4.1", "next-auth": "^4.22.1", "prettier": "^3.0.0", diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index 17391d65c1..1d54864357 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -27,7 +27,7 @@ export const logNextSteps = async ({ } } - const drizzleInUse = packages?.["drizzle"]; + const drizzleInUse = packages?.drizzle; if (packages?.prisma.inUse || drizzleInUse) { logger.info(` ${pkgManager === "npm" ? "npx" : pkgManager} db:push`); } diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 8a9becf451..16d9666608 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -1,5 +1,4 @@ import { DrizzleAdapter } from "@next-auth/drizzle-adapter"; -import { and, eq } from "drizzle-orm"; import { type GetServerSidePropsContext } from "next"; import { getServerSession, diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index 884e0075e4..4b9b97dc70 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -5,7 +5,6 @@ import { mysqlTableCreator, primaryKey, serial, - text, timestamp, uniqueIndex, varchar, From d7afbfabedc6e7b9dbc5191818a202ef443b3e5e Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:54:09 +0200 Subject: [PATCH 19/71] fix --- cli/src/cli/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index c001fe7c26..9595a7066a 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -246,8 +246,7 @@ export const runCli = async (): Promise => { options: [ { value: "none", label: "None" }, { value: "prisma", label: "Prisma" }, - { value: "drizzle-pscale", label: "Drizzle w/ PlanetScale" }, - { value: "drizzle-pg", label: "Drizzle w/ PostgreSQL" }, + { value: "drizzle", label: "Drizzle" }, ], initialValue: "none", }); From 74cdef36f5c16d2baecf2f403481e8161719db87 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 22:59:56 +0200 Subject: [PATCH 20/71] fix and move --- cli/package.json | 1 + cli/src/helpers/logNextSteps.ts | 10 ++--- cli/src/installers/dependencyVersionMap.ts | 2 +- cli/src/installers/nextAuth.ts | 2 +- .../extras/src/server/auth/with-drizzle.ts | 2 +- pnpm-lock.yaml | 44 +++++++++++++++++++ 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/cli/package.json b/cli/package.json index b9d969569a..0c6ffc0b16 100644 --- a/cli/package.json +++ b/cli/package.json @@ -54,6 +54,7 @@ "sort-package-json": "^2.4.1" }, "devDependencies": { + "@auth/drizzle-adapter": "^0.2.1", "@planetscale/database": "^1.7.0", "@prisma/client": "^4.14.0", "@t3-oss/env-nextjs": "^0.3.1", diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index 1d54864357..b4680c8d22 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -34,15 +34,15 @@ export const logNextSteps = async ({ logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} dev`); + if (!(await isInsideGitRepo(projectDir)) && !isRootGitRepo(projectDir)) { + logger.info(` git init`); + } + logger.info(` git commit -m "initial commit"`); + if (drizzleInUse) { logger.warn( `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, `\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.` ); } - - if (!(await isInsideGitRepo(projectDir)) && !isRootGitRepo(projectDir)) { - logger.info(` git init`); - } - logger.info(` git commit -m "initial commit"`); }; diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 2e6746ad05..d24ee5e224 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -6,7 +6,7 @@ export const dependencyVersionMap = { // NextAuth.js "next-auth": "^4.22.4", "@next-auth/prisma-adapter": "^1.0.7", - "@next-auth/drizzle-adapter": "^0.2.1", + "@auth/drizzle-adapter": "^0.2.1", // Prisma prisma: "^5.1.1", diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index ab2e36282a..40b52fc019 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -13,7 +13,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const deps: AvailableDependencies[] = ["next-auth"]; if (usingPrisma) deps.push("@next-auth/prisma-adapter"); // This adapter is not yet available on npm so we have our own inhoused - if (usingDrizzle) deps.push("@next-auth/drizzle-adapter"); + if (usingDrizzle) deps.push("@auth/drizzle-adapter"); addPackageDependency({ projectDir, diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 16d9666608..89391fd84a 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -1,4 +1,4 @@ -import { DrizzleAdapter } from "@next-auth/drizzle-adapter"; +import { DrizzleAdapter } from "@auth/drizzle-adapter"; import { type GetServerSidePropsContext } from "next"; import { getServerSession, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e39d687238..797a43cd28 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,6 +98,9 @@ importers: specifier: ^2.4.1 version: 2.4.1 devDependencies: + '@auth/drizzle-adapter': + specifier: ^0.2.1 + version: 0.2.1 '@planetscale/database': specifier: ^1.7.0 version: 1.7.0 @@ -782,6 +785,30 @@ packages: dependencies: undici: 5.22.1 + /@auth/core@0.10.1: + resolution: {integrity: sha512-zTE9cMRaAeTHvB78nRMovXW0D6ZnT3ldoGU+2PD5YAC+1G591LdOc4qjVaCyg5vmGjcTlHOpB4ApzyXXQkS1dA==} + peerDependencies: + nodemailer: ^6.8.0 + peerDependenciesMeta: + nodemailer: + optional: true + dependencies: + '@panva/hkdf': 1.0.4 + cookie: 0.5.0 + jose: 4.13.1 + oauth4webapi: 2.3.0 + preact: 10.11.3 + preact-render-to-string: 5.2.3(preact@10.11.3) + dev: true + + /@auth/drizzle-adapter@0.2.1: + resolution: {integrity: sha512-RGIiFGTrmWYYNeGw2KUX1WyTtsUNjSevSTf2c+3bdoUT73sfvarHaxLZ3qdI/+UyEdQVMiNkescU8fLqqQCOVg==} + dependencies: + '@auth/core': 0.10.1 + transitivePeerDependencies: + - nodemailer + dev: true + /@babel/code-frame@7.22.5: resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==} engines: {node: '>=6.9.0'} @@ -7425,6 +7452,10 @@ packages: set-blocking: 2.0.0 dev: false + /oauth4webapi@2.3.0: + resolution: {integrity: sha512-JGkb5doGrwzVDuHwgrR4nHJayzN4h59VCed6EW8Tql6iHDfZIabCJvg6wtbn5q6pyB2hZruI3b77Nudvq7NmvA==} + dev: true + /oauth@0.9.15: resolution: {integrity: sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==} dev: true @@ -7854,6 +7885,15 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 + /preact-render-to-string@5.2.3(preact@10.11.3): + resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==} + peerDependencies: + preact: '>=10' + dependencies: + preact: 10.11.3 + pretty-format: 3.8.0 + dev: true + /preact-render-to-string@5.2.6(preact@10.13.1): resolution: {integrity: sha512-JyhErpYOvBV1hEPwIxc/fHWXPfnEGdRKxc8gFdAZ7XV4tlzyzG847XAyEZqoDnynP88akM4eaHcSOzNcLWFguw==} peerDependencies: @@ -7863,6 +7903,10 @@ packages: pretty-format: 3.8.0 dev: true + /preact@10.11.3: + resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==} + dev: true + /preact@10.13.1: resolution: {integrity: sha512-KyoXVDU5OqTpG9LXlB3+y639JAGzl8JSBXLn1J9HTSB3gbKcuInga7bZnXLlxmK94ntTs1EFeZp0lrja2AuBYQ==} dev: true From d47195ec0cb49c4612f8dff194f84161ba272630 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:02:29 +0200 Subject: [PATCH 21/71] bumps --- cli/package.json | 22 +++++++++++----------- cli/src/installers/dependencyVersionMap.ts | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cli/package.json b/cli/package.json index 0c6ffc0b16..f0e4fe7074 100644 --- a/cli/package.json +++ b/cli/package.json @@ -55,22 +55,22 @@ }, "devDependencies": { "@auth/drizzle-adapter": "^0.2.1", - "@planetscale/database": "^1.7.0", - "@prisma/client": "^4.14.0", - "@t3-oss/env-nextjs": "^0.3.1", - "@tanstack/react-query": "^4.29.7", - "@trpc/client": "^10.26.0", - "@trpc/next": "^10.26.0", - "@trpc/react-query": "^10.26.0", - "@trpc/server": "^10.26.0", + "@planetscale/database": "^1.10.0", + "@prisma/client": "^5.1.1", + "@t3-oss/env-nextjs": "^0.6.0", + "@tanstack/react-query": "^4.32.6", + "@trpc/client": "^10.37.1", + "@trpc/next": "^10.37.1", + "@trpc/react-query": "^10.37.1", + "@trpc/server": "^10.37.1", "@types/fs-extra": "^11.0.1", "@types/gradient-string": "^1.1.2", "@types/inquirer": "^9.0.3", "@types/node": "^18.16.0", "drizzle-kit": "^0.19.12", - "drizzle-orm": "^0.26.5", - "next": "^13.4.1", - "next-auth": "^4.22.1", + "drizzle-orm": "^0.28.2", + "next": "^13.4.13", + "next-auth": "^4.22.5", "prettier": "^3.0.0", "prettier-plugin-tailwindcss": "^0.5.1", "prisma": "^4.14.0", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index d24ee5e224..cfa44ec68a 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -4,7 +4,7 @@ */ export const dependencyVersionMap = { // NextAuth.js - "next-auth": "^4.22.4", + "next-auth": "^4.22.5", "@next-auth/prisma-adapter": "^1.0.7", "@auth/drizzle-adapter": "^0.2.1", @@ -13,10 +13,10 @@ export const dependencyVersionMap = { "@prisma/client": "^5.1.1", // Drizzle - "drizzle-orm": "^0.26.3", - "drizzle-kit": "^0.18.1", + "drizzle-orm": "^0.28.2", + "drizzle-kit": "^0.19.12", dotenv: "^16.1.4", - "@planetscale/database": "^1.7.0", + "@planetscale/database": "^1.10.0", // TailwindCSS tailwindcss: "^3.3.3", @@ -26,11 +26,11 @@ export const dependencyVersionMap = { "prettier-plugin-tailwindcss": "^0.5.1", // tRPC - "@trpc/client": "^10.34.0", - "@trpc/server": "^10.34.0", - "@trpc/react-query": "^10.34.0", - "@trpc/next": "^10.34.0", - "@tanstack/react-query": "^4.29.25", + "@trpc/client": "^10.37.1", + "@trpc/server": "^10.37.1", + "@trpc/react-query": "^10.37.1", + "@trpc/next": "^10.37.1", + "@tanstack/react-query": "^4.32.6", superjson: "^1.13.1", } as const; export type AvailableDependencies = keyof typeof dependencyVersionMap; From b805566be498812772b47ac16a05aa493f60a347 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:03:30 +0200 Subject: [PATCH 22/71] fixxx --- pnpm-lock.yaml | 290 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 224 insertions(+), 66 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 797a43cd28..98855255bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -102,29 +102,29 @@ importers: specifier: ^0.2.1 version: 0.2.1 '@planetscale/database': - specifier: ^1.7.0 - version: 1.7.0 + specifier: ^1.10.0 + version: 1.10.0 '@prisma/client': - specifier: ^4.14.0 - version: 4.14.0(prisma@4.14.0) + specifier: ^5.1.1 + version: 5.1.1(prisma@4.14.0) '@t3-oss/env-nextjs': - specifier: ^0.3.1 - version: 0.3.1(typescript@5.0.4)(zod@3.21.4) + specifier: ^0.6.0 + version: 0.6.0(typescript@5.0.4)(zod@3.21.4) '@tanstack/react-query': - specifier: ^4.29.7 - version: 4.29.7(react-dom@18.2.0)(react@18.2.0) + specifier: ^4.32.6 + version: 4.32.6(react-dom@18.2.0)(react@18.2.0) '@trpc/client': - specifier: ^10.26.0 - version: 10.26.0(@trpc/server@10.26.0) + specifier: ^10.37.1 + version: 10.37.1(@trpc/server@10.37.1) '@trpc/next': - specifier: ^10.26.0 - version: 10.26.0(@tanstack/react-query@4.29.7)(@trpc/client@10.26.0)(@trpc/react-query@10.26.0)(@trpc/server@10.26.0)(next@13.4.1)(react-dom@18.2.0)(react@18.2.0) + specifier: ^10.37.1 + version: 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) '@trpc/react-query': - specifier: ^10.26.0 - version: 10.26.0(@tanstack/react-query@4.29.7)(@trpc/client@10.26.0)(@trpc/server@10.26.0)(react-dom@18.2.0)(react@18.2.0) + specifier: ^10.37.1 + version: 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/server@10.37.1)(react-dom@18.2.0)(react@18.2.0) '@trpc/server': - specifier: ^10.26.0 - version: 10.26.0 + specifier: ^10.37.1 + version: 10.37.1 '@types/fs-extra': specifier: ^11.0.1 version: 11.0.1 @@ -141,14 +141,14 @@ importers: specifier: ^0.19.12 version: 0.19.12 drizzle-orm: - specifier: ^0.26.5 - version: 0.26.5(@planetscale/database@1.7.0) + specifier: ^0.28.2 + version: 0.28.2(@planetscale/database@1.10.0) next: - specifier: ^13.4.1 - version: 13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + specifier: ^13.4.13 + version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: ^4.22.1 - version: 4.22.1(next@13.4.1)(react-dom@18.2.0)(react@18.2.0) + specifier: ^4.22.5 + version: 4.22.5(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) prettier: specifier: ^3.0.0 version: 3.0.0 @@ -1970,6 +1970,11 @@ packages: /@next/env@13.4.1: resolution: {integrity: sha512-eD6WCBMFjLFooLM19SIhSkWBHtaFrZFfg2Cxnyl3vS3DAdFRfnx5TY2RxlkuKXdIRCC0ySbtK9JXXt8qLCqzZg==} + dev: false + + /@next/env@13.4.13: + resolution: {integrity: sha512-fwz2QgVg08v7ZL7KmbQBLF2PubR/6zQdKBgmHEl3BCyWTEDsAQEijjw2gbFhI1tcKfLdOOJUXntz5vZ4S0Polg==} + dev: true /@next/eslint-plugin-next@13.4.1: resolution: {integrity: sha512-tVPS/2FKlA3ANCRCYZVT5jdbUKasBU8LG6bYqcNhyORDFTlDYa4cAWQJjZ7msIgLwMQIbL8CAsxrOL8maa/4Lg==} @@ -1998,6 +2003,16 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /@next/swc-darwin-arm64@13.4.13: + resolution: {integrity: sha512-ZptVhHjzUuivnXMNCJ6lER33HN7lC+rZ01z+PM10Ows21NHFYMvGhi5iXkGtBDk6VmtzsbqnAjnx4Oz5um0FjA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true optional: true /@next/swc-darwin-x64@13.4.1: @@ -2006,6 +2021,16 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /@next/swc-darwin-x64@13.4.13: + resolution: {integrity: sha512-t9nTiWCLApw8W4G1kqJyYP7y6/7lyal3PftmRturIxAIBlZss9wrtVN8nci50StDHmIlIDxfguYIEGVr9DbFTg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true optional: true /@next/swc-linux-arm64-gnu@13.4.1: @@ -2014,6 +2039,16 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-gnu@13.4.13: + resolution: {integrity: sha512-xEHUqC8eqR5DHe8SOmMnDU1K3ggrJ28uIKltrQAwqFSSSmzjnN/XMocZkcVhuncuxYrpbri0iMQstRyRVdQVWg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-arm64-musl@13.4.1: @@ -2022,6 +2057,16 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-musl@13.4.13: + resolution: {integrity: sha512-sNf3MnLAm8rquSSAoeD9nVcdaDeRYOeey4stOWOyWIgbBDtP+C93amSgH/LPTDoUV7gNiU6f+ghepTjTjRgIUQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-x64-gnu@13.4.1: @@ -2030,6 +2075,16 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-gnu@13.4.13: + resolution: {integrity: sha512-WhcRaJJSHyx9OWmKjjz+OWHumiPZWRqmM/09Bt7Up4UqUJFFhGExeztR4trtv3rflvULatu9IH/nTV8fUUgaMA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-x64-musl@13.4.1: @@ -2038,6 +2093,16 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-musl@13.4.13: + resolution: {integrity: sha512-+Y4LLhOWWZQIDKVwr2R17lq2KSN0F1c30QVgGIWfnjjHpH8nrIWHEndhqYU+iFuW8It78CiJjQKTw4f51HD7jA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-win32-arm64-msvc@13.4.1: @@ -2046,6 +2111,16 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-arm64-msvc@13.4.13: + resolution: {integrity: sha512-rWurdOR20uxjfqd1X9vDAgv0Jb26KjyL8akF9CBeFqX8rVaBAnW/Wf6A2gYEwyYY4Bai3T7p1kro6DFrsvBAAw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true optional: true /@next/swc-win32-ia32-msvc@13.4.1: @@ -2054,6 +2129,16 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-ia32-msvc@13.4.13: + resolution: {integrity: sha512-E8bSPwRuY5ibJ3CzLQmJEt8qaWrPYuUTwnrwygPUEWoLzD5YRx9SD37oXRdU81TgGwDzCxpl7z5Nqlfk50xAog==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true optional: true /@next/swc-win32-x64-msvc@13.4.1: @@ -2062,6 +2147,16 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-x64-msvc@13.4.13: + resolution: {integrity: sha512-4KlyC6jWRubPnppgfYsNTPeWfGCxtWLh5vaOAW/kdzAk9widqho8Qb5S4K2vHmal1tsURi7Onk2MMCV1phvyqA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true optional: true /@nodelib/fs.scandir@2.1.5: @@ -2136,14 +2231,14 @@ packages: tiny-glob: 0.2.9 tslib: 2.5.0 - /@planetscale/database@1.7.0: - resolution: {integrity: sha512-lWR6biXChUyQnxsT4RT1CIeR3ZJvwTQXiQ+158MnY3VjLwjHEGakDzdH9kwUGPk6CHvu6UeqRXp1DgUOVHJFTw==} + /@planetscale/database@1.10.0: + resolution: {integrity: sha512-XMfNRjIPgGTga6g1YpGr7E21CcnHZcHZdyhRUIiZ/AlpD+ts65UF2B3wKjcu7MKMynmmcOGs6R9kAT6D1OTlZQ==} engines: {node: '>=16'} dev: true - /@prisma/client@4.14.0(prisma@4.14.0): - resolution: {integrity: sha512-MK/XaA2sFdfaOa7I9MjNKz6dxeIEdeZlnpNRoF2w3JuRLlFJLkpp6cD3yaqw2nUUhbrn3Iqe3ZpVV+VuGGil7Q==} - engines: {node: '>=14.17'} + /@prisma/client@5.1.1(prisma@4.14.0): + resolution: {integrity: sha512-fxcCeK5pMQGcgCqCrWsi+I2rpIbk0rAhdrN+ke7f34tIrgPwA68ensrpin+9+fZvuV2OtzHmuipwduSY6HswdA==} + engines: {node: '>=16.13'} requiresBuild: true peerDependencies: prisma: '*' @@ -2151,12 +2246,12 @@ packages: prisma: optional: true dependencies: - '@prisma/engines-version': 4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c + '@prisma/engines-version': 5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e prisma: 4.14.0 dev: true - /@prisma/engines-version@4.14.0-67.d9a4c5988f480fa576d43970d5a23641aa77bc9c: - resolution: {integrity: sha512-3jum8/YSudeSN0zGW5qkpz+wAN2V/NYCQ+BPjvHYDfWatLWlQkqy99toX0GysDeaUoBIJg1vaz2yKqiA3CFcQw==} + /@prisma/engines-version@5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e: + resolution: {integrity: sha512-owZqbY/wucbr65bXJ/ljrHPgQU5xXTSkmcE/JcbqE1kusuAXV/TLN3/exmz21SZ5rJ7WDkyk70J2G/n68iogbQ==} dev: true /@prisma/engines@4.14.0: @@ -2720,6 +2815,17 @@ packages: dependencies: typescript: 5.0.4 zod: 3.21.4 + dev: false + + /@t3-oss/env-core@0.6.0(typescript@5.0.4)(zod@3.21.4): + resolution: {integrity: sha512-3FkPAba069WRZVVab/sB1m3eSGn/rZeypx5k+sWEu1d+k0OQdRDnvFS+7MtxYgqVrwaRk3b7yVnX2dgSPVmWPQ==} + peerDependencies: + typescript: '>=4.7.2' + zod: ^3.0.0 + dependencies: + typescript: 5.0.4 + zod: 3.21.4 + dev: true /@t3-oss/env-nextjs@0.3.1(typescript@5.0.4)(zod@3.21.4): resolution: {integrity: sha512-W1OgOn5xtpdEGraAQesyLzO2aNLRfSJEyK6qjQFfEUnrPbkvB+WxABX2bPMqfn4KJQ8pziLCSdBFiUN8OagqAg==} @@ -2730,13 +2836,25 @@ packages: '@t3-oss/env-core': 0.3.1(typescript@5.0.4)(zod@3.21.4) typescript: 5.0.4 zod: 3.21.4 + dev: false + + /@t3-oss/env-nextjs@0.6.0(typescript@5.0.4)(zod@3.21.4): + resolution: {integrity: sha512-SpzcGNIbUYcQw4zPPFeRJqCC1560zL7QmB0puIqOnuCsmykPkqHPX+n9CNZLXVQerboHzfvb7Kd+jAdouk72Vw==} + peerDependencies: + typescript: '>=4.7.2' + zod: ^3.0.0 + dependencies: + '@t3-oss/env-core': 0.6.0(typescript@5.0.4)(zod@3.21.4) + typescript: 5.0.4 + zod: 3.21.4 + dev: true - /@tanstack/query-core@4.29.7: - resolution: {integrity: sha512-GXG4b5hV2Loir+h2G+RXhJdoZhJLnrBWsuLB2r0qBRyhWuXq9w/dWxzvpP89H0UARlH6Mr9DiVj4SMtpkF/aUA==} + /@tanstack/query-core@4.32.6: + resolution: {integrity: sha512-YVB+mVWENQwPyv+40qO7flMgKZ0uI41Ph7qXC2Zf1ft5AIGfnXnMZyifB2ghhZ27u+5wm5mlzO4Y6lwwadzxCA==} dev: true - /@tanstack/react-query@4.29.7(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-ijBWEzAIo09fB1yd22slRZzprrZ5zMdWYzBnCg5qiXuFbH78uGN1qtGz8+Ed4MuhaPaYSD+hykn+QEKtQviEtg==} + /@tanstack/react-query@4.32.6(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-AITu/IKJJJXsHHeXNBy5bclu12t08usMCY0vFC2dh9SP/w6JAk5U9GwfjOIPj3p+ATADZvxQPe8UiCtMLNeQbg==} peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -2747,7 +2865,7 @@ packages: react-native: optional: true dependencies: - '@tanstack/query-core': 4.29.7 + '@tanstack/query-core': 4.32.6 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) use-sync-external-store: 1.2.0(react@18.2.0) @@ -2757,53 +2875,53 @@ packages: resolution: {integrity: sha512-yXt2BRRVCJVvzWaxac5n0nCXzIrQEBE/MeYlNQ8/Iq7UeelNmm/AdnUAu18ilSS893mbEQ4u6whPt/HvOPc4rw==} dev: false - /@trpc/client@10.26.0(@trpc/server@10.26.0): - resolution: {integrity: sha512-ojHxQFIE97rBEGPK8p1ijbzo0T1IdEBoJ9fFSgWWL9FMuEEA/DNQ9s0uuiOrDKhCCdTFT1unfRharoJhB2/O2w==} + /@trpc/client@10.37.1(@trpc/server@10.37.1): + resolution: {integrity: sha512-OSblNfeI0Z9ERn3usgLV2x63CwwPoNOHf1FQK85cOT7F8MNaWyEHoEv7tHUwNGJwyzKXmpU+ockZ0movzX3D0g==} peerDependencies: - '@trpc/server': 10.26.0 + '@trpc/server': 10.37.1 dependencies: - '@trpc/server': 10.26.0 + '@trpc/server': 10.37.1 dev: true - /@trpc/next@10.26.0(@tanstack/react-query@4.29.7)(@trpc/client@10.26.0)(@trpc/react-query@10.26.0)(@trpc/server@10.26.0)(next@13.4.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-p328crXBH6C228LKxjqbpDEXdLmy4+LdgsZuYK3oFMqaJEmCT22b+zcQ9IvQrcPfDxhKOpJym0QpuDNaWpG2qg==} + /@trpc/next@10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-0KEgr09mBfao56lkj7ZBfVOY86d3+bDH1o0zJkDHSH60Dp/hIJ7wLCnZJIhePlZxEwknCQjVeLsTy4Pqlu8NyQ==} peerDependencies: '@tanstack/react-query': ^4.18.0 - '@trpc/client': 10.26.0 - '@trpc/react-query': 10.26.0 - '@trpc/server': 10.26.0 + '@trpc/client': 10.37.1 + '@trpc/react-query': 10.37.1 + '@trpc/server': 10.37.1 next: '*' react: '>=16.8.0' react-dom: '>=16.8.0' dependencies: - '@tanstack/react-query': 4.29.7(react-dom@18.2.0)(react@18.2.0) - '@trpc/client': 10.26.0(@trpc/server@10.26.0) - '@trpc/react-query': 10.26.0(@tanstack/react-query@4.29.7)(@trpc/client@10.26.0)(@trpc/server@10.26.0)(react-dom@18.2.0)(react@18.2.0) - '@trpc/server': 10.26.0 - next: 13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + '@tanstack/react-query': 4.32.6(react-dom@18.2.0)(react@18.2.0) + '@trpc/client': 10.37.1(@trpc/server@10.37.1) + '@trpc/react-query': 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/server@10.37.1)(react-dom@18.2.0)(react@18.2.0) + '@trpc/server': 10.37.1 + next: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-ssr-prepass: 1.5.0(react@18.2.0) dev: true - /@trpc/react-query@10.26.0(@tanstack/react-query@4.29.7)(@trpc/client@10.26.0)(@trpc/server@10.26.0)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-n+enpalaCZhd3A/mbZmXeydRZHsAJo7mzc2ncgHn5S+C3SrfOM897uQdbHdj02Li25ULxzP1O92w+vZzmFbgkA==} + /@trpc/react-query@10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/server@10.37.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-TbOOPp0fZVaKfaeEyDoV8QeTHW1vgPTbfOs0uSQ4AzBXqXPu+9v1B44z8GGRJSdUxuOX9pG/6Ap5Kx8PQ3eF+Q==} peerDependencies: '@tanstack/react-query': ^4.18.0 - '@trpc/client': 10.26.0 - '@trpc/server': 10.26.0 + '@trpc/client': 10.37.1 + '@trpc/server': 10.37.1 react: '>=16.8.0' react-dom: '>=16.8.0' dependencies: - '@tanstack/react-query': 4.29.7(react-dom@18.2.0)(react@18.2.0) - '@trpc/client': 10.26.0(@trpc/server@10.26.0) - '@trpc/server': 10.26.0 + '@tanstack/react-query': 4.32.6(react-dom@18.2.0)(react@18.2.0) + '@trpc/client': 10.37.1(@trpc/server@10.37.1) + '@trpc/server': 10.37.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) dev: true - /@trpc/server@10.26.0: - resolution: {integrity: sha512-+Wt0NFAeflVSNiUnHIDNN3C8jP7XIRmYrcgJ6IsAnm0lK4p/FkpCpeu1aig5qxrgZx30PHNDLZ/3FttVSEW2aQ==} + /@trpc/server@10.37.1: + resolution: {integrity: sha512-r3VeA319/braYMBIzj+XLgLKQ9lJSVglvPvP9HUv4kr5w6Y5grQMxMcExhTiZWltE9bnSJHKtBBzHafOo7KC8A==} dev: true /@types/acorn@4.0.6: @@ -3932,6 +4050,7 @@ packages: /caniuse-lite@1.0.30001469: resolution: {integrity: sha512-Rcp7221ScNqQPP3W+lVOYDyjdR6dC+neEQCttoNr5bAyz54AboB4iwpnWgyi8P4YUsPybVzT4LgWiBbI3drL4g==} + dev: false /caniuse-lite@1.0.30001515: resolution: {integrity: sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==} @@ -4474,8 +4593,8 @@ packages: - supports-color dev: true - /drizzle-orm@0.26.5(@planetscale/database@1.7.0): - resolution: {integrity: sha512-ajjbOIoXqldWoWBn0RbVQCCT732R4Ad+gUjUrlmMpzWYwgnbG/qqPy84NhHntQ/MR//z3xfvT1Z2fD8uCAPX3g==} + /drizzle-orm@0.28.2(@planetscale/database@1.10.0): + resolution: {integrity: sha512-QRyuzvpJr7GE6LpvZ/sg2nAKNg2if1uGGkgFTiXn4auuYId//vVJe6HBsDTktfKfcaDGzIYos+/f+PS5EkBmrg==} peerDependencies: '@aws-sdk/client-rds-data': '>=3' '@cloudflare/workers-types': '>=3' @@ -4536,7 +4655,7 @@ packages: sqlite3: optional: true dependencies: - '@planetscale/database': 1.7.0 + '@planetscale/database': 1.10.0 dev: true /dset@3.1.2: @@ -5564,7 +5683,6 @@ packages: /glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - dev: false /glob@7.1.6: resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==} @@ -7292,8 +7410,8 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: false - /next-auth@4.22.1(next@13.4.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-NTR3f6W7/AWXKw8GSsgSyQcDW6jkslZLH8AiZa5PQ09w1kR8uHtR9rez/E9gAq/o17+p0JYHE8QjF3RoniiObA==} + /next-auth@4.22.5(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-zPVEpqDp4cx1y0HbonCSrz2sA4qw0grTMd/S0PezUKXvDzmVemtsJnfNK/xo5pO2sz5ilM541+EVCTp9QoRLbA==} peerDependencies: next: ^12.2.5 || ^13 nodemailer: ^6.6.5 @@ -7307,7 +7425,7 @@ packages: '@panva/hkdf': 1.0.4 cookie: 0.5.0 jose: 4.13.1 - next: 13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + next: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) oauth: 0.9.15 openid-client: 5.4.0 preact: 10.13.1 @@ -7364,6 +7482,47 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros + dev: false + + /next@13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-A3YVbVDNeXLhWsZ8Nf6IkxmNlmTNz0yVg186NJ97tGZqPDdPzTrHotJ+A1cuJm2XfuWPrKOUZILl5iBQkIf8Jw==} + engines: {node: '>=16.8.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + react: ^18.2.0 + react-dom: ^18.2.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + sass: + optional: true + dependencies: + '@next/env': 13.4.13 + '@swc/helpers': 0.5.1 + busboy: 1.6.0 + caniuse-lite: 1.0.30001515 + postcss: 8.4.14 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + styled-jsx: 5.1.1(@babel/core@7.22.9)(react@18.2.0) + watchpack: 2.4.0 + zod: 3.21.4 + optionalDependencies: + '@next/swc-darwin-arm64': 13.4.13 + '@next/swc-darwin-x64': 13.4.13 + '@next/swc-linux-arm64-gnu': 13.4.13 + '@next/swc-linux-arm64-musl': 13.4.13 + '@next/swc-linux-x64-gnu': 13.4.13 + '@next/swc-linux-x64-musl': 13.4.13 + '@next/swc-win32-arm64-msvc': 13.4.13 + '@next/swc-win32-ia32-msvc': 13.4.13 + '@next/swc-win32-x64-msvc': 13.4.13 + transitivePeerDependencies: + - '@babel/core' + - babel-plugin-macros + dev: true /nlcst-to-string@3.1.1: resolution: {integrity: sha512-63mVyqaqt0cmn2VcI2aH6kxe1rLAmSROqHMA0i4qqg1tidkfExgpb0FGMikMCn86mw5dFtBtEANfmSSK7TjNHw==} @@ -9895,7 +10054,6 @@ packages: dependencies: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 - dev: false /wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} From 1ed43023c8a192c678ea500e263e0309bcd2dbe6 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:04:02 +0200 Subject: [PATCH 23/71] fixxxx --- pnpm-lock.yaml | 176 +------------------------------------------ upgrade/package.json | 4 +- 2 files changed, 6 insertions(+), 174 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98855255bf..23e9b74b9d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -210,8 +210,8 @@ importers: specifier: ^1.0.1 version: 1.0.1(react@18.2.0) '@t3-oss/env-nextjs': - specifier: ^0.3.1 - version: 0.3.1(typescript@5.0.4)(zod@3.21.4) + specifier: ^0.6.0 + version: 0.6.0(typescript@5.0.4)(zod@3.21.4) class-variance-authority: specifier: ^0.6.0 version: 0.6.0(typescript@5.0.4) @@ -225,8 +225,8 @@ importers: specifier: ^0.216.0 version: 0.216.0(react@18.2.0) next: - specifier: ^13.4.1 - version: 13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + specifier: ^13.4.13 + version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -1968,13 +1968,8 @@ packages: - supports-color dev: false - /@next/env@13.4.1: - resolution: {integrity: sha512-eD6WCBMFjLFooLM19SIhSkWBHtaFrZFfg2Cxnyl3vS3DAdFRfnx5TY2RxlkuKXdIRCC0ySbtK9JXXt8qLCqzZg==} - dev: false - /@next/env@13.4.13: resolution: {integrity: sha512-fwz2QgVg08v7ZL7KmbQBLF2PubR/6zQdKBgmHEl3BCyWTEDsAQEijjw2gbFhI1tcKfLdOOJUXntz5vZ4S0Polg==} - dev: true /@next/eslint-plugin-next@13.4.1: resolution: {integrity: sha512-tVPS/2FKlA3ANCRCYZVT5jdbUKasBU8LG6bYqcNhyORDFTlDYa4cAWQJjZ7msIgLwMQIbL8CAsxrOL8maa/4Lg==} @@ -1997,31 +1992,12 @@ packages: source-map: 0.7.4 dev: false - /@next/swc-darwin-arm64@13.4.1: - resolution: {integrity: sha512-eF8ARHtYfnoYtDa6xFHriUKA/Mfj/cCbmKb3NofeKhMccs65G6/loZ15a6wYCCx4rPAd6x4t1WmVYtri7EdeBg==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@next/swc-darwin-arm64@13.4.13: resolution: {integrity: sha512-ZptVhHjzUuivnXMNCJ6lER33HN7lC+rZ01z+PM10Ows21NHFYMvGhi5iXkGtBDk6VmtzsbqnAjnx4Oz5um0FjA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] requiresBuild: true - dev: true - optional: true - - /@next/swc-darwin-x64@13.4.1: - resolution: {integrity: sha512-7cmDgF9tGWTgn5Gw+vP17miJbH4wcraMHDCOHTYWkO/VeKT73dUWG23TNRLfgtCNSPgH4V5B4uLHoZTanx9bAw==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: false optional: true /@next/swc-darwin-x64@13.4.13: @@ -2030,16 +2006,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm64-gnu@13.4.1: - resolution: {integrity: sha512-qwJqmCri2ie8aTtE5gjTSr8S6O8B67KCYgVZhv9gKH44yvc/zXbAY8u23QGULsYOyh1islWE5sWfQNLOj9iryg==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-gnu@13.4.13: @@ -2048,16 +2014,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm64-musl@13.4.1: - resolution: {integrity: sha512-qcC54tWNGDv/VVIFkazxhqH1Bnagjfs4enzELVRlUOoJPD2BGJTPI7z08pQPbbgxLtRiu8gl2mXvpB8WlOkMeA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-musl@13.4.13: @@ -2066,16 +2022,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-x64-gnu@13.4.1: - resolution: {integrity: sha512-9TeWFlpLsBosZ+tsm/rWBaMwt5It9tPH8m3nawZqFUUrZyGRfGcI67js774vtx0k3rL9qbyY6+3pw9BCVpaYUA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-gnu@13.4.13: @@ -2084,16 +2030,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-x64-musl@13.4.1: - resolution: {integrity: sha512-sNDGaWmSqTS4QRUzw61wl4mVPeSqNIr1OOjLlQTRuyInxMxtqImRqdvzDvFTlDfdeUMU/DZhWGYoHrXLlZXe6A==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-musl@13.4.13: @@ -2102,16 +2038,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-arm64-msvc@13.4.1: - resolution: {integrity: sha512-+CXZC7u1iXdLRudecoUYbhbsXpglYv8KFYsFxKBPn7kg+bk7eJo738wAA4jXIl8grTF2mPdmO93JOQym+BlYGA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-arm64-msvc@13.4.13: @@ -2120,16 +2046,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-ia32-msvc@13.4.1: - resolution: {integrity: sha512-vIoXVVc7UYO68VwVMDKwJC2+HqAZQtCYiVlApyKEeIPIQpz2gpufzGxk1z3/gwrJt/kJ5CDZjlhYDCzd3hdz+g==} - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-ia32-msvc@13.4.13: @@ -2138,16 +2054,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-x64-msvc@13.4.1: - resolution: {integrity: sha512-n8V5ImLQZibKTu10UUdI3nIeTLkliEXe628qxqW9v8My3BAH2a7H0SaCqkV2OgqFnn8sG1wxKYw9/SNJ632kSA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-x64-msvc@13.4.13: @@ -2156,7 +2062,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: true optional: true /@nodelib/fs.scandir@2.1.5: @@ -2807,16 +2712,6 @@ packages: defer-to-connect: 1.1.3 dev: false - /@t3-oss/env-core@0.3.1(typescript@5.0.4)(zod@3.21.4): - resolution: {integrity: sha512-iEnBuWeSjzqQLDTUw7H+YhstV4OZrGXTkQGL6ZOMxZQoCmwGX7GVS+1KCd5RvCzOtrIAD9jeOItSWNjC7sG4Sg==} - peerDependencies: - typescript: '>=4.7.2' - zod: ^3.0.0 - dependencies: - typescript: 5.0.4 - zod: 3.21.4 - dev: false - /@t3-oss/env-core@0.6.0(typescript@5.0.4)(zod@3.21.4): resolution: {integrity: sha512-3FkPAba069WRZVVab/sB1m3eSGn/rZeypx5k+sWEu1d+k0OQdRDnvFS+7MtxYgqVrwaRk3b7yVnX2dgSPVmWPQ==} peerDependencies: @@ -2825,18 +2720,6 @@ packages: dependencies: typescript: 5.0.4 zod: 3.21.4 - dev: true - - /@t3-oss/env-nextjs@0.3.1(typescript@5.0.4)(zod@3.21.4): - resolution: {integrity: sha512-W1OgOn5xtpdEGraAQesyLzO2aNLRfSJEyK6qjQFfEUnrPbkvB+WxABX2bPMqfn4KJQ8pziLCSdBFiUN8OagqAg==} - peerDependencies: - typescript: '>=4.7.2' - zod: ^3.0.0 - dependencies: - '@t3-oss/env-core': 0.3.1(typescript@5.0.4)(zod@3.21.4) - typescript: 5.0.4 - zod: 3.21.4 - dev: false /@t3-oss/env-nextjs@0.6.0(typescript@5.0.4)(zod@3.21.4): resolution: {integrity: sha512-SpzcGNIbUYcQw4zPPFeRJqCC1560zL7QmB0puIqOnuCsmykPkqHPX+n9CNZLXVQerboHzfvb7Kd+jAdouk72Vw==} @@ -2847,7 +2730,6 @@ packages: '@t3-oss/env-core': 0.6.0(typescript@5.0.4)(zod@3.21.4) typescript: 5.0.4 zod: 3.21.4 - dev: true /@tanstack/query-core@4.32.6: resolution: {integrity: sha512-YVB+mVWENQwPyv+40qO7flMgKZ0uI41Ph7qXC2Zf1ft5AIGfnXnMZyifB2ghhZ27u+5wm5mlzO4Y6lwwadzxCA==} @@ -4048,10 +3930,6 @@ packages: resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} dev: false - /caniuse-lite@1.0.30001469: - resolution: {integrity: sha512-Rcp7221ScNqQPP3W+lVOYDyjdR6dC+neEQCttoNr5bAyz54AboB4iwpnWgyi8P4YUsPybVzT4LgWiBbI3drL4g==} - dev: false - /caniuse-lite@1.0.30001515: resolution: {integrity: sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==} @@ -7439,51 +7317,6 @@ packages: resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} dev: true - /next@13.4.1(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-JBw2kAIyhKDpjhEWvNVoFeIzNp9xNxg8wrthDOtMctfn3EpqGCmW0FSviNyGgOSOSn6zDaX48pmvbdf6X2W9xA==} - engines: {node: '>=16.8.0'} - hasBin: true - peerDependencies: - '@opentelemetry/api': ^1.1.0 - fibers: '>= 3.1.0' - node-sass: ^6.0.0 || ^7.0.0 - react: ^18.2.0 - react-dom: ^18.2.0 - sass: ^1.3.0 - peerDependenciesMeta: - '@opentelemetry/api': - optional: true - fibers: - optional: true - node-sass: - optional: true - sass: - optional: true - dependencies: - '@next/env': 13.4.1 - '@swc/helpers': 0.5.1 - busboy: 1.6.0 - caniuse-lite: 1.0.30001469 - postcss: 8.4.14 - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - styled-jsx: 5.1.1(@babel/core@7.22.9)(react@18.2.0) - zod: 3.21.4 - optionalDependencies: - '@next/swc-darwin-arm64': 13.4.1 - '@next/swc-darwin-x64': 13.4.1 - '@next/swc-linux-arm64-gnu': 13.4.1 - '@next/swc-linux-arm64-musl': 13.4.1 - '@next/swc-linux-x64-gnu': 13.4.1 - '@next/swc-linux-x64-musl': 13.4.1 - '@next/swc-win32-arm64-msvc': 13.4.1 - '@next/swc-win32-ia32-msvc': 13.4.1 - '@next/swc-win32-x64-msvc': 13.4.1 - transitivePeerDependencies: - - '@babel/core' - - babel-plugin-macros - dev: false - /next@13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-A3YVbVDNeXLhWsZ8Nf6IkxmNlmTNz0yVg186NJ97tGZqPDdPzTrHotJ+A1cuJm2XfuWPrKOUZILl5iBQkIf8Jw==} engines: {node: '>=16.8.0'} @@ -7522,7 +7355,6 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros - dev: true /nlcst-to-string@3.1.1: resolution: {integrity: sha512-63mVyqaqt0cmn2VcI2aH6kxe1rLAmSROqHMA0i4qqg1tidkfExgpb0FGMikMCn86mw5dFtBtEANfmSSK7TjNHw==} diff --git a/upgrade/package.json b/upgrade/package.json index 1563a8239f..6d6e627922 100644 --- a/upgrade/package.json +++ b/upgrade/package.json @@ -23,12 +23,12 @@ "@radix-ui/react-label": "^2.0.1", "@radix-ui/react-select": "^1.2.1", "@radix-ui/react-slot": "^1.0.1", - "@t3-oss/env-nextjs": "^0.3.1", + "@t3-oss/env-nextjs": "^0.6.0", "class-variance-authority": "^0.6.0", "clsx": "^1.2.1", "gitdiff-parser": "^0.3.1", "lucide-react": "^0.216.0", - "next": "^13.4.1", + "next": "^13.4.13", "react": "18.2.0", "react-diff-view": "^3.0.3", "react-dom": "18.2.0", From 62b72925d7f1f08e0d4f6de5dd6bbba975d8fcb7 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:07:36 +0200 Subject: [PATCH 24/71] add cast --- cli/template/extras/src/server/auth/with-drizzle.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 89391fd84a..9166d824da 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -5,6 +5,7 @@ import { type DefaultSession, type NextAuthOptions, } from "next-auth"; +import { Adapter } from "next-auth/adapters"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env.mjs"; @@ -47,7 +48,7 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: DrizzleAdapter(db, mysqlTable), + adapter: DrizzleAdapter(db, mysqlTable) as Adapter, providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, From 24897924e6b9f45d1d12d67f3d39ca8375c737e9 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:09:11 +0200 Subject: [PATCH 25/71] fixxx --- pnpm-lock.yaml | 8 ++++---- upgrade/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 23e9b74b9d..6a004c5324 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -222,8 +222,8 @@ importers: specifier: ^0.3.1 version: 0.3.1 lucide-react: - specifier: ^0.216.0 - version: 0.216.0(react@18.2.0) + specifier: ^0.263.1 + version: 0.263.1(react@18.2.0) next: specifier: ^13.4.13 version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) @@ -6568,8 +6568,8 @@ packages: es5-ext: 0.10.62 dev: true - /lucide-react@0.216.0(react@18.2.0): - resolution: {integrity: sha512-PGWXs6JXI/08rhfkmj/joji0MAKDCcms44j0LYILO4J36AWqKhgjjaZ6WECRSyZ9TQe5gOrAR0g38O8cKrQngw==} + /lucide-react@0.263.1(react@18.2.0): + resolution: {integrity: sha512-keqxAx97PlaEN89PXZ6ki1N8nRjGWtDa4021GFYLNj0RgruM5odbpl8GHTExj0hhPq3sF6Up0gnxt6TSHu+ovw==} peerDependencies: react: ^16.5.1 || ^17.0.0 || ^18.0.0 dependencies: diff --git a/upgrade/package.json b/upgrade/package.json index 6d6e627922..907ad61377 100644 --- a/upgrade/package.json +++ b/upgrade/package.json @@ -27,7 +27,7 @@ "class-variance-authority": "^0.6.0", "clsx": "^1.2.1", "gitdiff-parser": "^0.3.1", - "lucide-react": "^0.216.0", + "lucide-react": "^0.263.1", "next": "^13.4.13", "react": "18.2.0", "react-diff-view": "^3.0.3", From 9738590e2fa9ff71bd4eb4640f5d11d47e2697af Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:11:06 +0200 Subject: [PATCH 26/71] fixxx --- cli/src/installers/envVars.ts | 8 +++++--- .../src/env/{with-auth-prisma.mjs => with-auth-db.mjs} | 0 2 files changed, 5 insertions(+), 3 deletions(-) rename cli/template/extras/src/env/{with-auth-prisma.mjs => with-auth-db.mjs} (100%) diff --git a/cli/src/installers/envVars.ts b/cli/src/installers/envVars.ts index b936e32a08..9b4e3a4233 100644 --- a/cli/src/installers/envVars.ts +++ b/cli/src/installers/envVars.ts @@ -9,14 +9,16 @@ export const envVariablesInstaller: Installer = ({ projectDir, packages }) => { const usingPrisma = packages?.prisma.inUse; const usingDrizzle = packages?.drizzle.inUse; + const usingDb = usingPrisma || usingDrizzle; + const envContent = getEnvContent(!!usingAuth, !!usingPrisma, !!usingDrizzle); const envFile = - usingAuth && usingPrisma - ? "with-auth-prisma.mjs" + usingAuth && usingDb + ? "with-auth-db.mjs" : usingAuth ? "with-auth.mjs" - : usingPrisma || usingDrizzle + : usingDb ? "with-db.mjs" : ""; diff --git a/cli/template/extras/src/env/with-auth-prisma.mjs b/cli/template/extras/src/env/with-auth-db.mjs similarity index 100% rename from cli/template/extras/src/env/with-auth-prisma.mjs rename to cli/template/extras/src/env/with-auth-db.mjs From d0c06f6437d6cb4012d917298b65816387cba3c1 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:24:17 +0200 Subject: [PATCH 27/71] lint fix --- cli/template/extras/src/server/auth/with-drizzle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 9166d824da..435a77b3dc 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -5,7 +5,7 @@ import { type DefaultSession, type NextAuthOptions, } from "next-auth"; -import { Adapter } from "next-auth/adapters"; +import { type Adapter } from "next-auth/adapters"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env.mjs"; From c62f5f250a390fce1f85856f20176f84a1c4998b Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:37:55 +0200 Subject: [PATCH 28/71] nuke inquirer completely --- cli/package.json | 1 - cli/src/cli/index.ts | 9 +-- cli/src/helpers/git.ts | 19 ++--- cli/src/helpers/scaffoldProject.ts | 29 +++----- pnpm-lock.yaml | 116 +---------------------------- 5 files changed, 18 insertions(+), 156 deletions(-) diff --git a/cli/package.json b/cli/package.json index f0e4fe7074..cbe578b1ff 100644 --- a/cli/package.json +++ b/cli/package.json @@ -49,7 +49,6 @@ "execa": "^7.1.1", "fs-extra": "^11.1.1", "gradient-string": "^2.0.2", - "inquirer": "^9.2.3", "ora": "6.3.1", "sort-package-json": "^2.4.1" }, diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 9595a7066a..20f2b66077 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -1,7 +1,6 @@ import * as p from "@clack/prompts"; import chalk from "chalk"; import { Command } from "commander"; -import inquirer from "inquirer"; import { CREATE_T3_APP, DEFAULT_APP_NAME } from "~/consts.js"; // import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; @@ -310,13 +309,9 @@ export const runCli = async (): Promise => { logger.warn(` ${CREATE_T3_APP} needs an interactive terminal to provide options`); - const { shouldContinue } = await inquirer.prompt<{ - shouldContinue: boolean; - }>({ - name: "shouldContinue", - type: "confirm", + const shouldContinue = await p.confirm({ message: `Continue scaffolding a default T3 app?`, - default: true, + initialValue: true, }); if (!shouldContinue) { diff --git a/cli/src/helpers/git.ts b/cli/src/helpers/git.ts index 4ad2a9ab29..527c7fd460 100644 --- a/cli/src/helpers/git.ts +++ b/cli/src/helpers/git.ts @@ -1,9 +1,9 @@ import { execSync } from "child_process"; import path from "path"; +import * as p from "@clack/prompts"; import chalk from "chalk"; import { execa } from "execa"; import fs from "fs-extra"; -import inquirer from "inquirer"; import ora from "ora"; import { logger } from "~/utils/logger.js"; @@ -72,16 +72,13 @@ export const initializeGit = async (projectDir: string) => { if (isInside && isRoot) { // Dir is a root git repo spinner.stop(); - const { overwriteGit } = await inquirer.prompt<{ - overwriteGit: boolean; - }>({ - name: "overwriteGit", - type: "confirm", + const overwriteGit = await p.confirm({ message: `${chalk.redBright.bold( "Warning:" )} Git is already initialized in "${dirName}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`, - default: false, + initialValue: false, }); + if (!overwriteGit) { spinner.info("Skipping Git initialization."); return; @@ -91,15 +88,11 @@ export const initializeGit = async (projectDir: string) => { } else if (isInside && !isRoot) { // Dir is inside a git worktree spinner.stop(); - const { initializeChildGitRepo } = await inquirer.prompt<{ - initializeChildGitRepo: boolean; - }>({ - name: "initializeChildGitRepo", - type: "confirm", + const initializeChildGitRepo = await p.confirm({ message: `${chalk.redBright.bold( "Warning:" )} "${dirName}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`, - default: false, + initialValue: false, }); if (!initializeChildGitRepo) { spinner.info("Skipping Git initialization."); diff --git a/cli/src/helpers/scaffoldProject.ts b/cli/src/helpers/scaffoldProject.ts index 62d8e92396..d4e6730798 100644 --- a/cli/src/helpers/scaffoldProject.ts +++ b/cli/src/helpers/scaffoldProject.ts @@ -1,7 +1,7 @@ import path from "path"; +import * as p from "@clack/prompts"; import chalk from "chalk"; import fs from "fs-extra"; -import inquirer from "inquirer"; import ora from "ora"; import { PKG_ROOT } from "~/consts.js"; @@ -33,32 +33,25 @@ export const scaffoldProject = async ({ ); } else { spinner.stopAndPersist(); - const { overwriteDir } = await inquirer.prompt<{ - overwriteDir: "abort" | "clear" | "overwrite"; - }>({ - name: "overwriteDir", - type: "list", + const overwriteDir = await p.select({ message: `${chalk.redBright.bold("Warning:")} ${chalk.cyan.bold( projectName )} already exists and isn't empty. How would you like to proceed?`, - choices: [ + options: [ { - name: "Abort installation (recommended)", + label: "Abort installation (recommended)", value: "abort", - short: "Abort", }, { - name: "Clear the directory and continue installation", + label: "Clear the directory and continue installation", value: "clear", - short: "Clear", }, { - name: "Continue installation and overwrite conflicting files", + label: "Continue installation and overwrite conflicting files", value: "overwrite", - short: "Overwrite", }, ], - default: "abort", + initialValue: "abort", }); if (overwriteDir === "abort") { spinner.fail("Aborting installation..."); @@ -70,13 +63,9 @@ export const scaffoldProject = async ({ ? "clear the directory" : "overwrite conflicting files"; - const { confirmOverwriteDir } = await inquirer.prompt<{ - confirmOverwriteDir: boolean; - }>({ - name: "confirmOverwriteDir", - type: "confirm", + const confirmOverwriteDir = await p.confirm({ message: `Are you sure you want to ${overwriteAction}?`, - default: false, + initialValue: false, }); if (!confirmOverwriteDir) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6a004c5324..1db4f45311 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,9 +88,6 @@ importers: gradient-string: specifier: ^2.0.2 version: 2.0.2 - inquirer: - specifier: ^9.2.3 - version: 9.2.3 ora: specifier: 6.3.1 version: 6.3.1 @@ -3449,13 +3446,6 @@ packages: engines: {node: '>=6'} dev: false - /ansi-escapes@4.3.2: - resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} - engines: {node: '>=8'} - dependencies: - type-fest: 0.21.3 - dev: false - /ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -4034,13 +4024,6 @@ packages: timers-ext: 0.1.7 dev: true - /cli-cursor@3.1.0: - resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} - engines: {node: '>=8'} - dependencies: - restore-cursor: 3.1.0 - dev: false - /cli-cursor@4.0.0: resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -4051,11 +4034,6 @@ packages: resolution: {integrity: sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==} engines: {node: '>=6'} - /cli-width@4.0.0: - resolution: {integrity: sha512-ZksGS2xpa/bYkNzN3BAw1wEjsLV/ZKOf/CCrJ/QOBsxx6fOARIkwTutxp1XIOIohi6HKmOFjMoK/XaqDVUpEEw==} - engines: {node: '>= 12'} - dev: false - /client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} @@ -5334,14 +5312,6 @@ packages: resolution: {integrity: sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==} dev: false - /figures@5.0.0: - resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} - engines: {node: '>=14'} - dependencies: - escape-string-regexp: 5.0.0 - is-unicode-supported: 1.3.0 - dev: false - /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -5985,27 +5955,6 @@ packages: resolution: {integrity: sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==} dev: false - /inquirer@9.2.3: - resolution: {integrity: sha512-/Et0+d28D7hnTYaqeCQkp3FYuD/X5cc2qbM6BzFdC5zs30oByoU5W/pmLc493FVVMwYmAILKjPBEmwRKTtknSQ==} - engines: {node: '>=14.18.0'} - dependencies: - ansi-escapes: 4.3.2 - chalk: 5.2.0 - cli-cursor: 3.1.0 - cli-width: 4.0.0 - external-editor: 3.1.0 - figures: 5.0.0 - lodash: 4.17.21 - mute-stream: 1.0.0 - ora: 5.4.1 - run-async: 3.0.0 - rxjs: 7.8.1 - string-width: 4.2.3 - strip-ansi: 6.0.1 - through: 2.3.8 - wrap-ansi: 6.2.0 - dev: false - /internal-slot@1.0.5: resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==} engines: {node: '>= 0.4'} @@ -6138,11 +6087,6 @@ packages: resolution: {integrity: sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==} dev: false - /is-interactive@1.0.0: - resolution: {integrity: sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==} - engines: {node: '>=8'} - dev: false - /is-interactive@2.0.0: resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==} engines: {node: '>=12'} @@ -6252,11 +6196,6 @@ packages: gopd: 1.0.1 has-tostringtag: 1.0.0 - /is-unicode-supported@0.1.0: - resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} - engines: {node: '>=10'} - dev: false - /is-unicode-supported@1.3.0: resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} engines: {node: '>=12'} @@ -6506,18 +6445,6 @@ packages: resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} dev: true - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: false - - /log-symbols@4.1.0: - resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==} - engines: {node: '>=10'} - dependencies: - chalk: 4.1.2 - is-unicode-supported: 0.1.0 - dev: false - /log-symbols@5.1.0: resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==} engines: {node: '>=12'} @@ -7258,11 +7185,6 @@ packages: /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - /mute-stream@1.0.0: - resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - dev: false - /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} dependencies: @@ -7568,21 +7490,6 @@ packages: type-check: 0.4.0 word-wrap: 1.2.3 - /ora@5.4.1: - resolution: {integrity: sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==} - engines: {node: '>=10'} - dependencies: - bl: 4.1.0 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-spinners: 2.7.0 - is-interactive: 1.0.0 - is-unicode-supported: 0.1.0 - log-symbols: 4.1.0 - strip-ansi: 6.0.1 - wcwidth: 1.0.1 - dev: false - /ora@6.3.1: resolution: {integrity: sha512-ERAyNnZOfqM+Ao3RAvIXkYh5joP220yf59gVe2X/cI6SiCxIdi4c9HZKZD8R6q/RDXEje1THBju6iExiSsgJaQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -8477,14 +8384,6 @@ packages: lowercase-keys: 1.0.1 dev: false - /restore-cursor@3.1.0: - resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} - engines: {node: '>=8'} - dependencies: - onetime: 5.1.2 - signal-exit: 3.0.7 - dev: false - /restore-cursor@4.0.0: resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -8548,11 +8447,6 @@ packages: optionalDependencies: fsevents: 2.3.2 - /run-async@3.0.0: - resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==} - engines: {node: '>=0.12.0'} - dev: false - /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: @@ -8562,6 +8456,7 @@ packages: resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} dependencies: tslib: 2.5.0 + dev: true /s.color@0.0.15: resolution: {integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==} @@ -9226,10 +9121,6 @@ packages: dependencies: any-promise: 1.3.0 - /through@2.3.8: - resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - dev: false - /timers-ext@0.1.7: resolution: {integrity: sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==} dependencies: @@ -9485,11 +9376,6 @@ packages: resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} engines: {node: '>=10'} - /type-fest@0.21.3: - resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} - engines: {node: '>=10'} - dev: false - /type-fest@0.6.0: resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} engines: {node: '>=8'} From be42a792b7c17419102841d1594f4d65ca01ffa3 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:38:42 +0200 Subject: [PATCH 29/71] changeset --- .changeset/eleven-pants-smash.md | 5 +++++ .changeset/fast-teachers-explain.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/eleven-pants-smash.md diff --git a/.changeset/eleven-pants-smash.md b/.changeset/eleven-pants-smash.md new file mode 100644 index 0000000000..8fdc9a69e7 --- /dev/null +++ b/.changeset/eleven-pants-smash.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": patch +--- + +refactor: swap inquirer for clack diff --git a/.changeset/fast-teachers-explain.md b/.changeset/fast-teachers-explain.md index b333cd99f9..8c7d8124a1 100644 --- a/.changeset/fast-teachers-explain.md +++ b/.changeset/fast-teachers-explain.md @@ -1,5 +1,5 @@ --- -"create-t3-app": patch +"create-t3-app": minor --- feat: add drizzle From 5b4d054fc35ceed31ab50424ec5e219bd2bcc30d Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 10 Aug 2023 23:57:37 +0200 Subject: [PATCH 30/71] fixx --- cli/src/helpers/logNextSteps.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index b4680c8d22..c56f545f94 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -27,8 +27,7 @@ export const logNextSteps = async ({ } } - const drizzleInUse = packages?.drizzle; - if (packages?.prisma.inUse || drizzleInUse) { + if (packages?.prisma.inUse || packages?.drizzle.inUse) { logger.info(` ${pkgManager === "npm" ? "npx" : pkgManager} db:push`); } @@ -39,7 +38,7 @@ export const logNextSteps = async ({ } logger.info(` git commit -m "initial commit"`); - if (drizzleInUse) { + if (packages?.drizzle.inUse) { logger.warn( `\nThank you for trying out the new Drizzle option. If you encounter any issues, please open an issue!`, `\nNote: We use the PlanetScale driver so that you can query your data in edge runtimes. If you want to use a different driver, you'll need to change it yourself.` From 3f78700972d2516a794c3e7d7087fdc74b70331f Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Fri, 11 Aug 2023 00:12:37 +0200 Subject: [PATCH 31/71] use env --- cli/template/extras/config/drizzle.config.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index e82e07e1d2..adc8c4de1b 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,18 +1,14 @@ import * as dotenv from "dotenv"; import { type Config } from "drizzle-kit"; -dotenv.config({ - path: "../../.env", -}); +import { env } from "~/env.mjs"; -if (!process.env.DATABASE_URL) { - throw new Error("DATABASE_URL is not set"); -} +dotenv.config(); export default { schema: "./schema", driver: "mysql2", dbCredentials: { - connectionString: process.env.DATABASE_URL, + connectionString: env.DATABASE_URL, }, } satisfies Config; From 815b027eb18f40fd8e31ac68672753834fda6f51 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:01:03 +0200 Subject: [PATCH 32/71] fixy --- cli/package.json | 5 +- cli/src/installers/dependencyVersionMap.ts | 6 +-- cli/src/installers/nextAuth.ts | 3 +- .../extras/src/server/auth/with-drizzle.ts | 3 +- .../extras/src/server/auth/with-prisma.ts | 2 +- .../src/server/db/drizzle-schema-auth.ts | 6 +-- pnpm-lock.yaml | 52 +++++++++++++++---- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/cli/package.json b/cli/package.json index cbe578b1ff..e571117036 100644 --- a/cli/package.json +++ b/cli/package.json @@ -53,7 +53,8 @@ "sort-package-json": "^2.4.1" }, "devDependencies": { - "@auth/drizzle-adapter": "^0.2.1", + "@auth/drizzle-adapter": "^0.3.1", + "@auth/prisma-adapter": "^1.0.1", "@planetscale/database": "^1.10.0", "@prisma/client": "^5.1.1", "@t3-oss/env-nextjs": "^0.6.0", @@ -69,7 +70,7 @@ "drizzle-kit": "^0.19.12", "drizzle-orm": "^0.28.2", "next": "^13.4.13", - "next-auth": "^4.22.5", + "next-auth": "^4.23.0", "prettier": "^3.0.0", "prettier-plugin-tailwindcss": "^0.5.1", "prisma": "^4.14.0", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index cfa44ec68a..ef172ec9fd 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -4,9 +4,9 @@ */ export const dependencyVersionMap = { // NextAuth.js - "next-auth": "^4.22.5", - "@next-auth/prisma-adapter": "^1.0.7", - "@auth/drizzle-adapter": "^0.2.1", + "next-auth": "^4.23.0", + "@auth/prisma-adapter": "^1.0.1", + "@auth/drizzle-adapter": "^0.3.1", // Prisma prisma: "^5.1.1", diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 40b52fc019..5bf8d07ed5 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -11,8 +11,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingDrizzle = packages?.drizzle.inUse; const deps: AvailableDependencies[] = ["next-auth"]; - if (usingPrisma) deps.push("@next-auth/prisma-adapter"); - // This adapter is not yet available on npm so we have our own inhoused + if (usingPrisma) deps.push("@auth/prisma-adapter"); if (usingDrizzle) deps.push("@auth/drizzle-adapter"); addPackageDependency({ diff --git a/cli/template/extras/src/server/auth/with-drizzle.ts b/cli/template/extras/src/server/auth/with-drizzle.ts index 435a77b3dc..89391fd84a 100644 --- a/cli/template/extras/src/server/auth/with-drizzle.ts +++ b/cli/template/extras/src/server/auth/with-drizzle.ts @@ -5,7 +5,6 @@ import { type DefaultSession, type NextAuthOptions, } from "next-auth"; -import { type Adapter } from "next-auth/adapters"; import DiscordProvider from "next-auth/providers/discord"; import { env } from "~/env.mjs"; @@ -48,7 +47,7 @@ export const authOptions: NextAuthOptions = { }, }), }, - adapter: DrizzleAdapter(db, mysqlTable) as Adapter, + adapter: DrizzleAdapter(db, mysqlTable), providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID, diff --git a/cli/template/extras/src/server/auth/with-prisma.ts b/cli/template/extras/src/server/auth/with-prisma.ts index cec71fc803..3b36f0f2ba 100644 --- a/cli/template/extras/src/server/auth/with-prisma.ts +++ b/cli/template/extras/src/server/auth/with-prisma.ts @@ -1,4 +1,4 @@ -import { PrismaAdapter } from "@next-auth/prisma-adapter"; +import { PrismaAdapter } from "@auth/prisma-adapter"; import { type GetServerSidePropsContext } from "next"; import { getServerSession, diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index 4b9b97dc70..8b3c162455 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -32,7 +32,7 @@ export const example = mysqlTable( }) ); -export const users = mysqlTable("users", { +export const users = mysqlTable("user", { id: varchar("id", { length: 255 }).notNull().primaryKey(), name: varchar("name", { length: 255 }), email: varchar("email", { length: 255 }).notNull(), @@ -48,7 +48,7 @@ export const usersRelations = relations(users, ({ many }) => ({ })); export const accounts = mysqlTable( - "accounts", + "account", { userId: varchar("userId", { length: 255 }).notNull(), type: varchar("type", { length: 255 }) @@ -75,7 +75,7 @@ export const accountsRelations = relations(accounts, ({ one }) => ({ })); export const sessions = mysqlTable( - "sessions", + "session", { sessionToken: varchar("sessionToken", { length: 255 }) .notNull() diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1db4f45311..0e7791fff2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,8 +96,11 @@ importers: version: 2.4.1 devDependencies: '@auth/drizzle-adapter': - specifier: ^0.2.1 - version: 0.2.1 + specifier: ^0.3.1 + version: 0.3.1 + '@auth/prisma-adapter': + specifier: ^1.0.1 + version: 1.0.1(@prisma/client@5.1.1) '@planetscale/database': specifier: ^1.10.0 version: 1.10.0 @@ -144,8 +147,8 @@ importers: specifier: ^13.4.13 version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: ^4.22.5 - version: 4.22.5(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) + specifier: ^4.23.0 + version: 4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) prettier: specifier: ^3.0.0 version: 3.0.0 @@ -782,8 +785,8 @@ packages: dependencies: undici: 5.22.1 - /@auth/core@0.10.1: - resolution: {integrity: sha512-zTE9cMRaAeTHvB78nRMovXW0D6ZnT3ldoGU+2PD5YAC+1G591LdOc4qjVaCyg5vmGjcTlHOpB4ApzyXXQkS1dA==} + /@auth/core@0.11.1: + resolution: {integrity: sha512-PzvebszgJ4NpQNz8Fsjn39oEY8MzULKppr7Um7DX/HLrS3zthgLY0yAnwkA+2/kxwAb36dIkX+C72q6TziiTaA==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -798,10 +801,37 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: true - /@auth/drizzle-adapter@0.2.1: - resolution: {integrity: sha512-RGIiFGTrmWYYNeGw2KUX1WyTtsUNjSevSTf2c+3bdoUT73sfvarHaxLZ3qdI/+UyEdQVMiNkescU8fLqqQCOVg==} + /@auth/core@0.9.0: + resolution: {integrity: sha512-W2WO0WCBg1T3P8+yjQPzurTQhPv6ecBYfJ2oE3uvXPAX5ZLWAMSjKFAIa9oLZy5pwrB+YehJZPnlIxVilhrVcg==} + peerDependencies: + nodemailer: ^6.8.0 + peerDependenciesMeta: + nodemailer: + optional: true + dependencies: + '@panva/hkdf': 1.0.4 + cookie: 0.5.0 + jose: 4.13.1 + oauth4webapi: 2.3.0 + preact: 10.11.3 + preact-render-to-string: 5.2.3(preact@10.11.3) + dev: true + + /@auth/drizzle-adapter@0.3.1: + resolution: {integrity: sha512-zSuewnrozY0EZYVrt2T5VY0R+wA3chXncanmUgvAgoX+pcussKMVFmnSrSYuc3i4vfM2qCmAa6S6dkSH5RViSA==} + dependencies: + '@auth/core': 0.11.1 + transitivePeerDependencies: + - nodemailer + dev: true + + /@auth/prisma-adapter@1.0.1(@prisma/client@5.1.1): + resolution: {integrity: sha512-sBp9l/jVr7l9y7rp2Pv6eoP7i8X2CgRNE3jDWJ0B/u+HnKRofXflD1cldPqRSAkJhqH3UxhVtMTEijT9FoofmQ==} + peerDependencies: + '@prisma/client': '>=2.26.0 || >=3 || >=4' dependencies: - '@auth/core': 0.10.1 + '@auth/core': 0.9.0 + '@prisma/client': 5.1.1(prisma@4.14.0) transitivePeerDependencies: - nodemailer dev: true @@ -7210,8 +7240,8 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: false - /next-auth@4.22.5(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-zPVEpqDp4cx1y0HbonCSrz2sA4qw0grTMd/S0PezUKXvDzmVemtsJnfNK/xo5pO2sz5ilM541+EVCTp9QoRLbA==} + /next-auth@4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-RgukcJkBdvsJwEfA+B80Wcowvtgy6tk8KKWffb7CMCdzcLO4fCCA6aB6sp/DZ2I0ISvWGnbVcO5KXmlan71igw==} peerDependencies: next: ^12.2.5 || ^13 nodemailer: ^6.6.5 From 73833369869e7d713327427398eb807ad3d7c2f7 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:07:15 +0200 Subject: [PATCH 33/71] replace project1 with projectname --- cli/src/cli/index.ts | 2 -- cli/src/installers/drizzle.ts | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 20f2b66077..29c5549302 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -3,9 +3,7 @@ import chalk from "chalk"; import { Command } from "commander"; import { CREATE_T3_APP, DEFAULT_APP_NAME } from "~/consts.js"; -// import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; import { type AvailablePackages } from "~/installers/index.js"; -// import { availablePackages } from "~/installers/index.js"; import { getVersion } from "~/utils/getT3Version.js"; import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; import { IsTTYError } from "~/utils/isTTYError.js"; diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 1e0031e2ae..c3d65e5862 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -6,7 +6,7 @@ import { PKG_ROOT } from "~/consts.js"; import { type Installer } from "~/installers/index.js"; import { addPackageDependency } from "~/utils/addPackageDependency.js"; -export const drizzleInstaller: Installer = ({ projectDir, packages }) => { +export const drizzleInstaller: Installer = ({ projectDir, packages, projectName }) => { addPackageDependency({ projectDir, dependencies: ["drizzle-kit", "dotenv"], @@ -32,6 +32,10 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { ); const schemaDest = path.join(projectDir, "src/server/db/schema.ts"); + // Replace placeholder table prefix with project name +let schemaContent = fs.readFileSync(schemaSrc, "utf-8"); + schemaContent = schemaContent.replace("project1_${name}", `${projectName}_\${name}`); + const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); const clientDest = path.join(projectDir, "src/server/db/index.ts"); @@ -45,7 +49,7 @@ export const drizzleInstaller: Installer = ({ projectDir, packages }) => { }; fs.copySync(configFile, configDest); - fs.copySync(schemaSrc, schemaDest); + fs.writeFileSync(schemaDest, schemaContent); fs.copySync(clientSrc, clientDest); fs.writeJSONSync(packageJsonPath, packageJsonContent, { spaces: 2, From 740a9054f8465131a12f888abad110fa3ca11b8d Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:10:07 +0200 Subject: [PATCH 34/71] mk dir first --- cli/src/installers/drizzle.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index c3d65e5862..46984eae0e 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -49,6 +49,7 @@ let schemaContent = fs.readFileSync(schemaSrc, "utf-8"); }; fs.copySync(configFile, configDest); + fs.mkdirSync(path.dirname(schemaDest), { recursive: true }); fs.writeFileSync(schemaDest, schemaContent); fs.copySync(clientSrc, clientDest); fs.writeJSONSync(packageJsonPath, packageJsonContent, { From 8c6aa8c08535dc6b9313c2651ff52213c5ce5bb0 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:33:48 +0200 Subject: [PATCH 35/71] rev --- cli/package.json | 2 +- cli/src/installers/dependencyVersionMap.ts | 2 +- cli/src/installers/nextAuth.ts | 2 +- .../extras/src/server/auth/with-prisma.ts | 2 +- pnpm-lock.yaml | 43 ++++++------------- 5 files changed, 17 insertions(+), 34 deletions(-) diff --git a/cli/package.json b/cli/package.json index e571117036..ffcab1d517 100644 --- a/cli/package.json +++ b/cli/package.json @@ -54,7 +54,7 @@ }, "devDependencies": { "@auth/drizzle-adapter": "^0.3.1", - "@auth/prisma-adapter": "^1.0.1", + "@next-auth/prisma-adapter": "^1.0.7", "@planetscale/database": "^1.10.0", "@prisma/client": "^5.1.1", "@t3-oss/env-nextjs": "^0.6.0", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index ef172ec9fd..f50cb4cfa3 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -5,7 +5,7 @@ export const dependencyVersionMap = { // NextAuth.js "next-auth": "^4.23.0", - "@auth/prisma-adapter": "^1.0.1", + "@next-auth/prisma-adapter": "^1.0.7", "@auth/drizzle-adapter": "^0.3.1", // Prisma diff --git a/cli/src/installers/nextAuth.ts b/cli/src/installers/nextAuth.ts index 5bf8d07ed5..f4a27ebdfc 100644 --- a/cli/src/installers/nextAuth.ts +++ b/cli/src/installers/nextAuth.ts @@ -11,7 +11,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => { const usingDrizzle = packages?.drizzle.inUse; const deps: AvailableDependencies[] = ["next-auth"]; - if (usingPrisma) deps.push("@auth/prisma-adapter"); + if (usingPrisma) deps.push("@next-auth/prisma-adapter"); if (usingDrizzle) deps.push("@auth/drizzle-adapter"); addPackageDependency({ diff --git a/cli/template/extras/src/server/auth/with-prisma.ts b/cli/template/extras/src/server/auth/with-prisma.ts index 3b36f0f2ba..cec71fc803 100644 --- a/cli/template/extras/src/server/auth/with-prisma.ts +++ b/cli/template/extras/src/server/auth/with-prisma.ts @@ -1,4 +1,4 @@ -import { PrismaAdapter } from "@auth/prisma-adapter"; +import { PrismaAdapter } from "@next-auth/prisma-adapter"; import { type GetServerSidePropsContext } from "next"; import { getServerSession, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e7791fff2..3af4808767 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,9 +98,9 @@ importers: '@auth/drizzle-adapter': specifier: ^0.3.1 version: 0.3.1 - '@auth/prisma-adapter': - specifier: ^1.0.1 - version: 1.0.1(@prisma/client@5.1.1) + '@next-auth/prisma-adapter': + specifier: ^1.0.7 + version: 1.0.7(@prisma/client@5.1.1)(next-auth@4.23.0) '@planetscale/database': specifier: ^1.10.0 version: 1.10.0 @@ -801,22 +801,6 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: true - /@auth/core@0.9.0: - resolution: {integrity: sha512-W2WO0WCBg1T3P8+yjQPzurTQhPv6ecBYfJ2oE3uvXPAX5ZLWAMSjKFAIa9oLZy5pwrB+YehJZPnlIxVilhrVcg==} - peerDependencies: - nodemailer: ^6.8.0 - peerDependenciesMeta: - nodemailer: - optional: true - dependencies: - '@panva/hkdf': 1.0.4 - cookie: 0.5.0 - jose: 4.13.1 - oauth4webapi: 2.3.0 - preact: 10.11.3 - preact-render-to-string: 5.2.3(preact@10.11.3) - dev: true - /@auth/drizzle-adapter@0.3.1: resolution: {integrity: sha512-zSuewnrozY0EZYVrt2T5VY0R+wA3chXncanmUgvAgoX+pcussKMVFmnSrSYuc3i4vfM2qCmAa6S6dkSH5RViSA==} dependencies: @@ -825,17 +809,6 @@ packages: - nodemailer dev: true - /@auth/prisma-adapter@1.0.1(@prisma/client@5.1.1): - resolution: {integrity: sha512-sBp9l/jVr7l9y7rp2Pv6eoP7i8X2CgRNE3jDWJ0B/u+HnKRofXflD1cldPqRSAkJhqH3UxhVtMTEijT9FoofmQ==} - peerDependencies: - '@prisma/client': '>=2.26.0 || >=3 || >=4' - dependencies: - '@auth/core': 0.9.0 - '@prisma/client': 5.1.1(prisma@4.14.0) - transitivePeerDependencies: - - nodemailer - dev: true - /@babel/code-frame@7.22.5: resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==} engines: {node: '>=6.9.0'} @@ -1995,6 +1968,16 @@ packages: - supports-color dev: false + /@next-auth/prisma-adapter@1.0.7(@prisma/client@5.1.1)(next-auth@4.23.0): + resolution: {integrity: sha512-Cdko4KfcmKjsyHFrWwZ//lfLUbcLqlyFqjd/nYE2m3aZ7tjMNUjpks47iw7NTCnXf+5UWz5Ypyt1dSs1EP5QJw==} + peerDependencies: + '@prisma/client': '>=2.26.0 || >=3' + next-auth: ^4 + dependencies: + '@prisma/client': 5.1.1(prisma@4.14.0) + next-auth: 4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) + dev: true + /@next/env@13.4.13: resolution: {integrity: sha512-fwz2QgVg08v7ZL7KmbQBLF2PubR/6zQdKBgmHEl3BCyWTEDsAQEijjw2gbFhI1tcKfLdOOJUXntz5vZ4S0Polg==} From c16e1085879b689888f69509299e436a6de015cb Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:37:09 +0200 Subject: [PATCH 36/71] fix undefined --- cli/src/helpers/createProject.ts | 1 + cli/src/installers/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 7eebc9bf02..800bad3cb0 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -31,6 +31,7 @@ export const createProject = async ({ // Install the selected packages installPackages({ + projectName, projectDir, pkgManager, packages, diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 0126111596..dc1ba8e58f 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -23,7 +23,7 @@ export interface InstallerOptions { pkgManager: PackageManager; noInstall: boolean; packages?: PkgInstallerMap; - projectName?: string; + projectName: string; } export type Installer = (opts: InstallerOptions) => void; From 2e818cdcd5119f208e9606e56af358fa1fcff437 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:44:48 +0200 Subject: [PATCH 37/71] fix prefix name --- cli/src/helpers/createProject.ts | 4 ++++ cli/src/index.ts | 1 + cli/src/installers/drizzle.ts | 4 ++-- cli/src/installers/index.ts | 1 + cli/src/utils/parseNameAndPath.ts | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/src/helpers/createProject.ts b/cli/src/helpers/createProject.ts index 800bad3cb0..74d768c8cd 100644 --- a/cli/src/helpers/createProject.ts +++ b/cli/src/helpers/createProject.ts @@ -9,12 +9,14 @@ import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; interface CreateProjectOptions { projectName: string; packages: PkgInstallerMap; + scopedAppName: string; noInstall: boolean; importAlias: string; } export const createProject = async ({ projectName, + scopedAppName, packages, noInstall, }: CreateProjectOptions) => { @@ -26,12 +28,14 @@ export const createProject = async ({ projectName, projectDir, pkgManager, + scopedAppName, noInstall, }); // Install the selected packages installPackages({ projectName, + scopedAppName, projectDir, pkgManager, packages, diff --git a/cli/src/index.ts b/cli/src/index.ts index 5541afa025..651f3cdb30 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -43,6 +43,7 @@ const main = async () => { const projectDir = await createProject({ projectName: appDir, + scopedAppName, packages: usePackages, importAlias: importAlias, noInstall, diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 65a4cf4925..d89509d600 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -9,7 +9,7 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const drizzleInstaller: Installer = ({ projectDir, packages, - projectName, +scopedAppName, }) => { addPackageDependency({ projectDir, @@ -40,7 +40,7 @@ export const drizzleInstaller: Installer = ({ let schemaContent = fs.readFileSync(schemaSrc, "utf-8"); schemaContent = schemaContent.replace( "project1_${name}", - `${projectName}_\${name}` + `${scopedAppName}_\${name}` ); const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index dc1ba8e58f..45bef9ef14 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -24,6 +24,7 @@ export interface InstallerOptions { noInstall: boolean; packages?: PkgInstallerMap; projectName: string; + scopedAppName: string; } export type Installer = (opts: InstallerOptions) => void; diff --git a/cli/src/utils/parseNameAndPath.ts b/cli/src/utils/parseNameAndPath.ts index 92dd20108d..2f311f34a5 100644 --- a/cli/src/utils/parseNameAndPath.ts +++ b/cli/src/utils/parseNameAndPath.ts @@ -22,7 +22,7 @@ export const parseNameAndPath = (rawInput: string) => { const paths = input.split("/"); - let appName = paths[paths.length - 1]; + let appName = paths[paths.length - 1]!; // If the user ran `npx create-t3-app .` or similar, the appName should be the current directory if (appName === ".") { From 604ac415850342e1685769d5269c285234cfe9f2 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sat, 12 Aug 2023 13:48:18 +0200 Subject: [PATCH 38/71] fix lint --- cli/src/installers/drizzle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index d89509d600..926d370fc3 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -9,7 +9,7 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js"; export const drizzleInstaller: Installer = ({ projectDir, packages, -scopedAppName, + scopedAppName, }) => { addPackageDependency({ projectDir, From ce5f31b08b8ed9d232c229efabf4878dc7106d0c Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 13 Aug 2023 22:38:11 +0200 Subject: [PATCH 39/71] use `CURRENT_TIMESTAMP` Closes #1525 --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 2 +- cli/template/extras/src/server/db/drizzle-schema-base.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index 8b3c162455..e75e64ad2f 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -24,7 +24,7 @@ export const example = mysqlTable( { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at").defaultNow().notNull(), + createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull(), updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index b64ea87eac..eff0145fc3 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -1,6 +1,7 @@ // Example model schema from the Drizzle docs // https://orm.drizzle.team/docs/sql-schema-declaration +import { sql } from "drizzle-orm"; import { mysqlTableCreator, serial, @@ -22,7 +23,7 @@ export const example = mysqlTable( { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at").defaultNow().notNull(), + createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull(), updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ From 07ab600b1a1b56363757fada784260489a2ef0e0 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 13 Aug 2023 22:40:24 +0200 Subject: [PATCH 40/71] use `text` --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index e75e64ad2f..c6099bff2e 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -8,6 +8,7 @@ import { timestamp, uniqueIndex, varchar, + text, } from "drizzle-orm/mysql-core"; import { type AdapterAccount } from "next-auth/adapters"; @@ -56,12 +57,12 @@ export const accounts = mysqlTable( .notNull(), provider: varchar("provider", { length: 255 }).notNull(), providerAccountId: varchar("providerAccountId", { length: 255 }).notNull(), - refresh_token: varchar("refresh_token", { length: 255 }), - access_token: varchar("access_token", { length: 255 }), + refresh_token: text("refresh_token"), + access_token: text("access_token"), expires_at: int("expires_at"), token_type: varchar("token_type", { length: 255 }), scope: varchar("scope", { length: 255 }), - id_token: varchar("id_token", { length: 255 }), + id_token: text("id_token"), session_state: varchar("session_state", { length: 255 }), }, (account) => ({ From fc031083c1933ae1bd563754357109d68129bc51 Mon Sep 17 00:00:00 2001 From: wiktrek <61013382+wiktrek@users.noreply.github.com> Date: Sun, 13 Aug 2023 22:43:01 +0200 Subject: [PATCH 41/71] added drizzle.config.ts to polish and english folder-structure (#1506) Co-authored-by: Julius Marminge --- www/src/pages/en/faq.mdx | 1 + www/src/pages/en/folder-structure.mdx | 7 +++++++ www/src/pages/pl/faq.md | 1 + www/src/pages/pl/folder-structure.mdx | 7 +++++++ 4 files changed, 16 insertions(+) diff --git a/www/src/pages/en/faq.mdx b/www/src/pages/en/faq.mdx index d78823a77d..9ada523637 100644 --- a/www/src/pages/en/faq.mdx +++ b/www/src/pages/en/faq.mdx @@ -21,6 +21,7 @@ If you are not familiar with the different technologies used in this project, pl - [Prisma](https://prisma.io) - [Tailwind CSS](https://tailwindcss.com) - [tRPC](https://trpc.io) +- [Drizzle](https://drizzle.team/) ## How do I keep my app up to date? diff --git a/www/src/pages/en/folder-structure.mdx b/www/src/pages/en/folder-structure.mdx index d10b0f3609..446e910953 100644 --- a/www/src/pages/en/folder-structure.mdx +++ b/www/src/pages/en/folder-structure.mdx @@ -203,3 +203,10 @@ The `prettier.config.mjs` file is used to configure Prettier to include the pret The `tsconfig.json` file is used to configure TypeScript. Some non-defaults, such as `strict mode`, have been enabled to ensure the best usage of TypeScript for Create T3 App and its libraries. See [TypeScript Docs](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [TypeScript Usage](usage/typescript) for more information.
+
+ +### `drizzle.config.ts` + +The `drizzle.config.ts` file is used to configure drizzle kit. See [the documentation](https://orm.drizzle.team/kit-docs/config-reference) for more information. + +
\ No newline at end of file diff --git a/www/src/pages/pl/faq.md b/www/src/pages/pl/faq.md index 4b286de7ec..a0b62d95d3 100644 --- a/www/src/pages/pl/faq.md +++ b/www/src/pages/pl/faq.md @@ -18,6 +18,7 @@ Jeżeli nie znasz poszczególnych technologi użytych w projekcie, skorzystaj z - [Prisma](https://prisma.io) - [Tailwind CSS](https://tailwindcss.com) - [tRPC](https://trpc.io) +- [Drizzle](https://drizzle.team/) ## Jak sprawić, by aplikacja była ciągle aktualna? diff --git a/www/src/pages/pl/folder-structure.mdx b/www/src/pages/pl/folder-structure.mdx index db132ae849..6567cfca17 100644 --- a/www/src/pages/pl/folder-structure.mdx +++ b/www/src/pages/pl/folder-structure.mdx @@ -203,3 +203,10 @@ Plik `prettier.config.mjs` jest używany do konfigurowania Prettiera. Dołącza Plik `tsconfig.json` jest używany do konfigurowania TypeScripta. Niektóre ustawienia zostały włączone (takie jak `strict mode`), aby zapewnić najlepsze użycie TypeScripta do Create T3 App i jej bibliotek. Po więcej informacji, zobacz [dokumentację TypeScripta](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) albo [korzystanie z TypeScripta](/pl/usage/typescript). +
+ +### `drizzle.config.ts` + +Plik `drizzle.config.ts` jest używany do konfigurowania Drizzle kit. Po więcej informacji przeczytaj [ich dokumentację](https://orm.drizzle.team/kit-docs/config-reference) + +
\ No newline at end of file From a885d95653ee8fe5d9512b614fca72dac4443dfb Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 13 Aug 2023 22:47:08 +0200 Subject: [PATCH 42/71] placeholder docs --- www/src/config.ts | 1 + www/src/pages/en/usage/drizzle.mdx | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 www/src/pages/en/usage/drizzle.mdx diff --git a/www/src/config.ts b/www/src/config.ts index f003da3d89..fea5bc399e 100644 --- a/www/src/config.ts +++ b/www/src/config.ts @@ -123,6 +123,7 @@ export const SIDEBAR: Sidebar = { { text: "Next.js", link: "en/usage/next-js" }, { text: "TypeScript", link: "en/usage/typescript" }, { text: "tRPC", link: "en/usage/trpc" }, + { text: "Drizzle", link: "en/usage/drizzle" }, { text: "Prisma", link: "en/usage/prisma" }, { text: "NextAuth.js", link: "en/usage/next-auth" }, { diff --git a/www/src/pages/en/usage/drizzle.mdx b/www/src/pages/en/usage/drizzle.mdx new file mode 100644 index 0000000000..aefe547554 --- /dev/null +++ b/www/src/pages/en/usage/drizzle.mdx @@ -0,0 +1,14 @@ +--- +title: Drizzle +description: Usage of Drizzle +layout: ../../../layouts/docs.astro +lang: en +isMdx: true +--- + +import Callout from "../../../components/docs/callout.tsx"; + + + The `drizzle` option is a new addition and no docs have yet been written. Contributions are welcome! + + From f6b65d1c26fe86b5dd462b73eeeeda106c9cad8b Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Sun, 20 Aug 2023 13:59:18 +0200 Subject: [PATCH 43/71] prettier --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 6 ++++-- cli/template/extras/src/server/db/drizzle-schema-base.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index c6099bff2e..9be03f2223 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -5,10 +5,10 @@ import { mysqlTableCreator, primaryKey, serial, + text, timestamp, uniqueIndex, varchar, - text, } from "drizzle-orm/mysql-core"; import { type AdapterAccount } from "next-auth/adapters"; @@ -25,7 +25,9 @@ export const example = mysqlTable( { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull(), + createdAt: timestamp("created_at") + .default(sql`CURRENT_TIMESTAMP`) + .notNull(), updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index eff0145fc3..05f708c28d 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -23,7 +23,9 @@ export const example = mysqlTable( { id: serial("id").primaryKey(), name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at").default(sql`CURRENT_TIMESTAMP`).notNull(), + createdAt: timestamp("created_at") + .default(sql`CURRENT_TIMESTAMP`) + .notNull(), updatedAt: timestamp("updatedAt").onUpdateNow(), }, (example) => ({ From c2a50baed2c8ca527510fc38fa2c740810353d65 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 27 Aug 2023 20:17:03 +0200 Subject: [PATCH 44/71] bump --- cli/package.json | 4 ++-- cli/src/installers/dependencyVersionMap.ts | 4 ++-- pnpm-lock.yaml | 28 +++++++++++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cli/package.json b/cli/package.json index ffcab1d517..53374139d8 100644 --- a/cli/package.json +++ b/cli/package.json @@ -53,9 +53,9 @@ "sort-package-json": "^2.4.1" }, "devDependencies": { - "@auth/drizzle-adapter": "^0.3.1", + "@auth/drizzle-adapter": "^0.3.2", "@next-auth/prisma-adapter": "^1.0.7", - "@planetscale/database": "^1.10.0", + "@planetscale/database": "^1.11.0", "@prisma/client": "^5.1.1", "@t3-oss/env-nextjs": "^0.6.0", "@tanstack/react-query": "^4.32.6", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index f50cb4cfa3..bd9de5625e 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -6,7 +6,7 @@ export const dependencyVersionMap = { // NextAuth.js "next-auth": "^4.23.0", "@next-auth/prisma-adapter": "^1.0.7", - "@auth/drizzle-adapter": "^0.3.1", + "@auth/drizzle-adapter": "^0.3.2", // Prisma prisma: "^5.1.1", @@ -16,7 +16,7 @@ export const dependencyVersionMap = { "drizzle-orm": "^0.28.2", "drizzle-kit": "^0.19.12", dotenv: "^16.1.4", - "@planetscale/database": "^1.10.0", + "@planetscale/database": "^1.11.0", // TailwindCSS tailwindcss: "^3.3.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac68ba8e4e..769204fcfb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,14 +96,14 @@ importers: version: 2.4.1 devDependencies: '@auth/drizzle-adapter': - specifier: ^0.3.1 - version: 0.3.1 + specifier: ^0.3.2 + version: 0.3.2 '@next-auth/prisma-adapter': specifier: ^1.0.7 version: 1.0.7(@prisma/client@5.1.1)(next-auth@4.23.0) '@planetscale/database': - specifier: ^1.10.0 - version: 1.10.0 + specifier: ^1.11.0 + version: 1.11.0 '@prisma/client': specifier: ^5.1.1 version: 5.1.1(prisma@4.14.0) @@ -142,7 +142,7 @@ importers: version: 0.19.12 drizzle-orm: specifier: ^0.28.2 - version: 0.28.2(@planetscale/database@1.10.0) + version: 0.28.2(@planetscale/database@1.11.0) next: specifier: ^13.4.13 version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) @@ -785,8 +785,8 @@ packages: dependencies: undici: 5.22.1 - /@auth/core@0.11.1: - resolution: {integrity: sha512-PzvebszgJ4NpQNz8Fsjn39oEY8MzULKppr7Um7DX/HLrS3zthgLY0yAnwkA+2/kxwAb36dIkX+C72q6TziiTaA==} + /@auth/core@0.12.0: + resolution: {integrity: sha512-XYipdAc/nKu014VOgpcPyLlj1ghWlnwyloaB1UjQd9ElZRZQ9YpSizzXGLON23t/a0FyabOBBl0/awD2tW58Rg==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -801,10 +801,10 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: true - /@auth/drizzle-adapter@0.3.1: - resolution: {integrity: sha512-zSuewnrozY0EZYVrt2T5VY0R+wA3chXncanmUgvAgoX+pcussKMVFmnSrSYuc3i4vfM2qCmAa6S6dkSH5RViSA==} + /@auth/drizzle-adapter@0.3.2: + resolution: {integrity: sha512-fHfzwaTomm/RKgFKBO5AJ8JTfR44rX1KX2ASaKRk+4jvVhDh9FCir5BV1Fv68b5ay7XBo9DtcNSQuZp4hbpLYw==} dependencies: - '@auth/core': 0.11.1 + '@auth/core': 0.12.0 transitivePeerDependencies: - nodemailer dev: true @@ -2322,8 +2322,8 @@ packages: tiny-glob: 0.2.9 tslib: 2.5.0 - /@planetscale/database@1.10.0: - resolution: {integrity: sha512-XMfNRjIPgGTga6g1YpGr7E21CcnHZcHZdyhRUIiZ/AlpD+ts65UF2B3wKjcu7MKMynmmcOGs6R9kAT6D1OTlZQ==} + /@planetscale/database@1.11.0: + resolution: {integrity: sha512-aWbU+D/IRHoDE9975y+Q4c+EwwAWxCPwFId+N1AhQVFXzbeJMkj6KN2iQtoi03elcLMRdfT+V3i9Z4WRw+/oIA==} engines: {node: '>=16'} dev: true @@ -4641,7 +4641,7 @@ packages: - supports-color dev: true - /drizzle-orm@0.28.2(@planetscale/database@1.10.0): + /drizzle-orm@0.28.2(@planetscale/database@1.11.0): resolution: {integrity: sha512-QRyuzvpJr7GE6LpvZ/sg2nAKNg2if1uGGkgFTiXn4auuYId//vVJe6HBsDTktfKfcaDGzIYos+/f+PS5EkBmrg==} peerDependencies: '@aws-sdk/client-rds-data': '>=3' @@ -4703,7 +4703,7 @@ packages: sqlite3: optional: true dependencies: - '@planetscale/database': 1.10.0 + '@planetscale/database': 1.11.0 dev: true /dset@3.1.2: From 532d070b9acd4a34373b9e711eff7e19afca62de Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 27 Aug 2023 20:20:00 +0200 Subject: [PATCH 45/71] bump --- cli/package.json | 8 +- cli/src/installers/dependencyVersionMap.ts | 4 +- cli/template/base/package.json | 2 +- pnpm-lock.yaml | 180 ++++++++++++++++++--- 4 files changed, 165 insertions(+), 29 deletions(-) diff --git a/cli/package.json b/cli/package.json index 53374139d8..b28c8a82e6 100644 --- a/cli/package.json +++ b/cli/package.json @@ -67,10 +67,10 @@ "@types/gradient-string": "^1.1.2", "@types/inquirer": "^9.0.3", "@types/node": "^18.16.0", - "drizzle-kit": "^0.19.12", - "drizzle-orm": "^0.28.2", - "next": "^13.4.13", - "next-auth": "^4.23.0", + "drizzle-kit": "^0.19.13", + "drizzle-orm": "^0.28.5", + "next": "^13.4.19", + "next-auth": "^4.23.1", "prettier": "^3.0.0", "prettier-plugin-tailwindcss": "^0.5.1", "prisma": "^4.14.0", diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index bd9de5625e..6b94c4b8da 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -13,8 +13,8 @@ export const dependencyVersionMap = { "@prisma/client": "^5.1.1", // Drizzle - "drizzle-orm": "^0.28.2", - "drizzle-kit": "^0.19.12", + "drizzle-orm": "^0.28.5", + "drizzle-kit": "^0.19.13", dotenv: "^16.1.4", "@planetscale/database": "^1.11.0", diff --git a/cli/template/base/package.json b/cli/template/base/package.json index e5d71365b7..c365787410 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@t3-oss/env-nextjs": "^0.6.0", - "next": "^13.4.13", + "next": "^13.4.19", "react": "18.2.0", "react-dom": "18.2.0", "zod": "^3.21.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 769204fcfb..31a706fc64 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -100,7 +100,7 @@ importers: version: 0.3.2 '@next-auth/prisma-adapter': specifier: ^1.0.7 - version: 1.0.7(@prisma/client@5.1.1)(next-auth@4.23.0) + version: 1.0.7(@prisma/client@5.1.1)(next-auth@4.23.1) '@planetscale/database': specifier: ^1.11.0 version: 1.11.0 @@ -118,7 +118,7 @@ importers: version: 10.37.1(@trpc/server@10.37.1) '@trpc/next': specifier: ^10.37.1 - version: 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) + version: 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.19)(react-dom@18.2.0)(react@18.2.0) '@trpc/react-query': specifier: ^10.37.1 version: 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/server@10.37.1)(react-dom@18.2.0)(react@18.2.0) @@ -138,17 +138,17 @@ importers: specifier: ^18.16.0 version: 18.16.1 drizzle-kit: - specifier: ^0.19.12 - version: 0.19.12 + specifier: ^0.19.13 + version: 0.19.13 drizzle-orm: - specifier: ^0.28.2 - version: 0.28.2(@planetscale/database@1.11.0) + specifier: ^0.28.5 + version: 0.28.5(@planetscale/database@1.11.0) next: - specifier: ^13.4.13 - version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + specifier: ^13.4.19 + version: 13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: ^4.23.0 - version: 4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) + specifier: ^4.23.1 + version: 4.23.1(next@13.4.19)(react-dom@18.2.0)(react@18.2.0) prettier: specifier: ^3.0.0 version: 3.0.0 @@ -1288,7 +1288,7 @@ packages: /@esbuild-kit/core-utils@3.1.0: resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==} dependencies: - esbuild: 0.17.12 + esbuild: 0.17.19 source-map-support: 0.5.21 dev: true @@ -2144,18 +2144,23 @@ packages: - supports-color dev: false - /@next-auth/prisma-adapter@1.0.7(@prisma/client@5.1.1)(next-auth@4.23.0): + /@next-auth/prisma-adapter@1.0.7(@prisma/client@5.1.1)(next-auth@4.23.1): resolution: {integrity: sha512-Cdko4KfcmKjsyHFrWwZ//lfLUbcLqlyFqjd/nYE2m3aZ7tjMNUjpks47iw7NTCnXf+5UWz5Ypyt1dSs1EP5QJw==} peerDependencies: '@prisma/client': '>=2.26.0 || >=3' next-auth: ^4 dependencies: '@prisma/client': 5.1.1(prisma@4.14.0) - next-auth: 4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0) + next-auth: 4.23.1(next@13.4.19)(react-dom@18.2.0)(react@18.2.0) dev: true /@next/env@13.4.13: resolution: {integrity: sha512-fwz2QgVg08v7ZL7KmbQBLF2PubR/6zQdKBgmHEl3BCyWTEDsAQEijjw2gbFhI1tcKfLdOOJUXntz5vZ4S0Polg==} + dev: false + + /@next/env@13.4.19: + resolution: {integrity: sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ==} + dev: true /@next/eslint-plugin-next@13.4.1: resolution: {integrity: sha512-tVPS/2FKlA3ANCRCYZVT5jdbUKasBU8LG6bYqcNhyORDFTlDYa4cAWQJjZ7msIgLwMQIbL8CAsxrOL8maa/4Lg==} @@ -2184,6 +2189,16 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /@next/swc-darwin-arm64@13.4.19: + resolution: {integrity: sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true optional: true /@next/swc-darwin-x64@13.4.13: @@ -2192,6 +2207,16 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /@next/swc-darwin-x64@13.4.19: + resolution: {integrity: sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true optional: true /@next/swc-linux-arm64-gnu@13.4.13: @@ -2200,6 +2225,16 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-gnu@13.4.19: + resolution: {integrity: sha512-vdlnIlaAEh6H+G6HrKZB9c2zJKnpPVKnA6LBwjwT2BTjxI7e0Hx30+FoWCgi50e+YO49p6oPOtesP9mXDRiiUg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-arm64-musl@13.4.13: @@ -2208,6 +2243,16 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-arm64-musl@13.4.19: + resolution: {integrity: sha512-aU0HkH2XPgxqrbNRBFb3si9Ahu/CpaR5RPmN2s9GiM9qJCiBBlZtRTiEca+DC+xRPyCThTtWYgxjWHgU7ZkyvA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-x64-gnu@13.4.13: @@ -2216,6 +2261,16 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-gnu@13.4.19: + resolution: {integrity: sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-linux-x64-musl@13.4.13: @@ -2224,6 +2279,16 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false + optional: true + + /@next/swc-linux-x64-musl@13.4.19: + resolution: {integrity: sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true /@next/swc-win32-arm64-msvc@13.4.13: @@ -2232,6 +2297,16 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-arm64-msvc@13.4.19: + resolution: {integrity: sha512-bUfDevQK4NsIAHXs3/JNgnvEY+LRyneDN788W2NYiRIIzmILjba7LaQTfihuFawZDhRtkYCv3JDC3B4TwnmRJw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true optional: true /@next/swc-win32-ia32-msvc@13.4.13: @@ -2240,6 +2315,16 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-ia32-msvc@13.4.19: + resolution: {integrity: sha512-Y5kikILFAr81LYIFaw6j/NrOtmiM4Sf3GtOc0pn50ez2GCkr+oejYuKGcwAwq3jiTKuzF6OF4iT2INPoxRycEA==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true optional: true /@next/swc-win32-x64-msvc@13.4.13: @@ -2248,6 +2333,16 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: false + optional: true + + /@next/swc-win32-x64-msvc@13.4.19: + resolution: {integrity: sha512-YzA78jBDXMYiINdPdJJwGgPNT3YqBNNGhsthsDoWHL9p24tEJn9ViQf/ZqTbwSpX/RrkPupLfuuTH2sf73JBAw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true optional: true /@nodelib/fs.scandir@2.1.5: @@ -2951,7 +3046,7 @@ packages: '@trpc/server': 10.37.1 dev: true - /@trpc/next@10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): + /@trpc/next@10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/react-query@10.37.1)(@trpc/server@10.37.1)(next@13.4.19)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-0KEgr09mBfao56lkj7ZBfVOY86d3+bDH1o0zJkDHSH60Dp/hIJ7wLCnZJIhePlZxEwknCQjVeLsTy4Pqlu8NyQ==} peerDependencies: '@tanstack/react-query': ^4.18.0 @@ -2966,7 +3061,7 @@ packages: '@trpc/client': 10.37.1(@trpc/server@10.37.1) '@trpc/react-query': 10.37.1(@tanstack/react-query@4.32.6)(@trpc/client@10.37.1)(@trpc/server@10.37.1)(react-dom@18.2.0)(react@18.2.0) '@trpc/server': 10.37.1 - next: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + next: 13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-ssr-prepass: 1.5.0(react@18.2.0) @@ -4621,8 +4716,8 @@ packages: wordwrap: 1.0.0 dev: true - /drizzle-kit@0.19.12: - resolution: {integrity: sha512-rcsmh5gUIkvuD0WrbEc+aLpqY2q2J8ltynRcJiJo2l01hhsYvPnX0sgxWlFXlfAIa5ZXNw2nJZhYlslI6tG3MA==} + /drizzle-kit@0.19.13: + resolution: {integrity: sha512-Rba5VW1O2JfJlwVBeZ8Zwt2E2us5oZ08PQBDiVSGlug53TOc8hzXjblZFuF+dnll9/RQEHrkzBmJFgqTvn5Rxg==} hasBin: true dependencies: '@drizzle-team/studio': 0.0.5 @@ -4641,8 +4736,8 @@ packages: - supports-color dev: true - /drizzle-orm@0.28.2(@planetscale/database@1.11.0): - resolution: {integrity: sha512-QRyuzvpJr7GE6LpvZ/sg2nAKNg2if1uGGkgFTiXn4auuYId//vVJe6HBsDTktfKfcaDGzIYos+/f+PS5EkBmrg==} + /drizzle-orm@0.28.5(@planetscale/database@1.11.0): + resolution: {integrity: sha512-6r6Iw4c38NAmW6TiKH3TUpGUQ1YdlEoLJOQptn8XPx3Z63+vFNKfAiANqrIiYZiMjKR9+NYAL219nFrmo1duXA==} peerDependencies: '@aws-sdk/client-rds-data': '>=3' '@cloudflare/workers-types': '>=3' @@ -7431,8 +7526,8 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: false - /next-auth@4.23.0(next@13.4.13)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-RgukcJkBdvsJwEfA+B80Wcowvtgy6tk8KKWffb7CMCdzcLO4fCCA6aB6sp/DZ2I0ISvWGnbVcO5KXmlan71igw==} + /next-auth@4.23.1(next@13.4.19)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-mL083z8KgRtlrIV6CDca2H1kduWJuK/3pTS0Fe2og15KOm4v2kkLGdSDfc2g+019aEBrJUT0pPW2Xx42ImN1WA==} peerDependencies: next: ^12.2.5 || ^13 nodemailer: ^6.6.5 @@ -7446,7 +7541,7 @@ packages: '@panva/hkdf': 1.0.4 cookie: 0.5.0 jose: 4.13.1 - next: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + next: 13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) oauth: 0.9.15 openid-client: 5.4.0 preact: 10.13.1 @@ -7498,6 +7593,47 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros + dev: false + + /next@13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==} + engines: {node: '>=16.8.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + react: ^18.2.0 + react-dom: ^18.2.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + sass: + optional: true + dependencies: + '@next/env': 13.4.19 + '@swc/helpers': 0.5.1 + busboy: 1.6.0 + caniuse-lite: 1.0.30001515 + postcss: 8.4.14 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + styled-jsx: 5.1.1(@babel/core@7.22.9)(react@18.2.0) + watchpack: 2.4.0 + zod: 3.21.4 + optionalDependencies: + '@next/swc-darwin-arm64': 13.4.19 + '@next/swc-darwin-x64': 13.4.19 + '@next/swc-linux-arm64-gnu': 13.4.19 + '@next/swc-linux-arm64-musl': 13.4.19 + '@next/swc-linux-x64-gnu': 13.4.19 + '@next/swc-linux-x64-musl': 13.4.19 + '@next/swc-win32-arm64-msvc': 13.4.19 + '@next/swc-win32-ia32-msvc': 13.4.19 + '@next/swc-win32-x64-msvc': 13.4.19 + transitivePeerDependencies: + - '@babel/core' + - babel-plugin-macros + dev: true /nlcst-to-string@3.1.1: resolution: {integrity: sha512-63mVyqaqt0cmn2VcI2aH6kxe1rLAmSROqHMA0i4qqg1tidkfExgpb0FGMikMCn86mw5dFtBtEANfmSSK7TjNHw==} From 532bda3837f572fbb156d3169200b0870a9f2979 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 27 Aug 2023 20:20:29 +0200 Subject: [PATCH 46/71] fix --- cli/template/base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/base/package.json b/cli/template/base/package.json index c365787410..ff123eb4f5 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -23,7 +23,7 @@ "@typescript-eslint/eslint-plugin": "^6.3.0", "@typescript-eslint/parser": "^6.3.0", "eslint": "^8.47.0", - "eslint-config-next": "^13.4.13", + "eslint-config-next": "^13.4.19", "typescript": "^5.1.6" } } From a9be92c765e778c18471601efbbca3325ee4bf9d Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 27 Aug 2023 20:22:17 +0200 Subject: [PATCH 47/71] fix manypkg --- pnpm-lock.yaml | 140 +------------------------------------------ upgrade/package.json | 2 +- 2 files changed, 3 insertions(+), 139 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 31a706fc64..04ba79d28d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,8 +225,8 @@ importers: specifier: ^0.263.1 version: 0.263.1(react@18.2.0) next: - specifier: ^13.4.13 - version: 13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) + specifier: ^13.4.19 + version: 13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -2154,13 +2154,8 @@ packages: next-auth: 4.23.1(next@13.4.19)(react-dom@18.2.0)(react@18.2.0) dev: true - /@next/env@13.4.13: - resolution: {integrity: sha512-fwz2QgVg08v7ZL7KmbQBLF2PubR/6zQdKBgmHEl3BCyWTEDsAQEijjw2gbFhI1tcKfLdOOJUXntz5vZ4S0Polg==} - dev: false - /@next/env@13.4.19: resolution: {integrity: sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ==} - dev: true /@next/eslint-plugin-next@13.4.1: resolution: {integrity: sha512-tVPS/2FKlA3ANCRCYZVT5jdbUKasBU8LG6bYqcNhyORDFTlDYa4cAWQJjZ7msIgLwMQIbL8CAsxrOL8maa/4Lg==} @@ -2183,31 +2178,12 @@ packages: source-map: 0.7.4 dev: false - /@next/swc-darwin-arm64@13.4.13: - resolution: {integrity: sha512-ZptVhHjzUuivnXMNCJ6lER33HN7lC+rZ01z+PM10Ows21NHFYMvGhi5iXkGtBDk6VmtzsbqnAjnx4Oz5um0FjA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@next/swc-darwin-arm64@13.4.19: resolution: {integrity: sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] requiresBuild: true - dev: true - optional: true - - /@next/swc-darwin-x64@13.4.13: - resolution: {integrity: sha512-t9nTiWCLApw8W4G1kqJyYP7y6/7lyal3PftmRturIxAIBlZss9wrtVN8nci50StDHmIlIDxfguYIEGVr9DbFTg==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: false optional: true /@next/swc-darwin-x64@13.4.19: @@ -2216,16 +2192,6 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm64-gnu@13.4.13: - resolution: {integrity: sha512-xEHUqC8eqR5DHe8SOmMnDU1K3ggrJ28uIKltrQAwqFSSSmzjnN/XMocZkcVhuncuxYrpbri0iMQstRyRVdQVWg==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-gnu@13.4.19: @@ -2234,16 +2200,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-arm64-musl@13.4.13: - resolution: {integrity: sha512-sNf3MnLAm8rquSSAoeD9nVcdaDeRYOeey4stOWOyWIgbBDtP+C93amSgH/LPTDoUV7gNiU6f+ghepTjTjRgIUQ==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-arm64-musl@13.4.19: @@ -2252,16 +2208,6 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-x64-gnu@13.4.13: - resolution: {integrity: sha512-WhcRaJJSHyx9OWmKjjz+OWHumiPZWRqmM/09Bt7Up4UqUJFFhGExeztR4trtv3rflvULatu9IH/nTV8fUUgaMA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-gnu@13.4.19: @@ -2270,16 +2216,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-linux-x64-musl@13.4.13: - resolution: {integrity: sha512-+Y4LLhOWWZQIDKVwr2R17lq2KSN0F1c30QVgGIWfnjjHpH8nrIWHEndhqYU+iFuW8It78CiJjQKTw4f51HD7jA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false optional: true /@next/swc-linux-x64-musl@13.4.19: @@ -2288,16 +2224,6 @@ packages: cpu: [x64] os: [linux] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-arm64-msvc@13.4.13: - resolution: {integrity: sha512-rWurdOR20uxjfqd1X9vDAgv0Jb26KjyL8akF9CBeFqX8rVaBAnW/Wf6A2gYEwyYY4Bai3T7p1kro6DFrsvBAAw==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-arm64-msvc@13.4.19: @@ -2306,16 +2232,6 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-ia32-msvc@13.4.13: - resolution: {integrity: sha512-E8bSPwRuY5ibJ3CzLQmJEt8qaWrPYuUTwnrwygPUEWoLzD5YRx9SD37oXRdU81TgGwDzCxpl7z5Nqlfk50xAog==} - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-ia32-msvc@13.4.19: @@ -2324,16 +2240,6 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true - dev: true - optional: true - - /@next/swc-win32-x64-msvc@13.4.13: - resolution: {integrity: sha512-4KlyC6jWRubPnppgfYsNTPeWfGCxtWLh5vaOAW/kdzAk9widqho8Qb5S4K2vHmal1tsURi7Onk2MMCV1phvyqA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: false optional: true /@next/swc-win32-x64-msvc@13.4.19: @@ -2342,7 +2248,6 @@ packages: cpu: [x64] os: [win32] requiresBuild: true - dev: true optional: true /@nodelib/fs.scandir@2.1.5: @@ -7555,46 +7460,6 @@ packages: resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} dev: true - /next@13.4.13(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-A3YVbVDNeXLhWsZ8Nf6IkxmNlmTNz0yVg186NJ97tGZqPDdPzTrHotJ+A1cuJm2XfuWPrKOUZILl5iBQkIf8Jw==} - engines: {node: '>=16.8.0'} - hasBin: true - peerDependencies: - '@opentelemetry/api': ^1.1.0 - react: ^18.2.0 - react-dom: ^18.2.0 - sass: ^1.3.0 - peerDependenciesMeta: - '@opentelemetry/api': - optional: true - sass: - optional: true - dependencies: - '@next/env': 13.4.13 - '@swc/helpers': 0.5.1 - busboy: 1.6.0 - caniuse-lite: 1.0.30001515 - postcss: 8.4.14 - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - styled-jsx: 5.1.1(@babel/core@7.22.9)(react@18.2.0) - watchpack: 2.4.0 - zod: 3.21.4 - optionalDependencies: - '@next/swc-darwin-arm64': 13.4.13 - '@next/swc-darwin-x64': 13.4.13 - '@next/swc-linux-arm64-gnu': 13.4.13 - '@next/swc-linux-arm64-musl': 13.4.13 - '@next/swc-linux-x64-gnu': 13.4.13 - '@next/swc-linux-x64-musl': 13.4.13 - '@next/swc-win32-arm64-msvc': 13.4.13 - '@next/swc-win32-ia32-msvc': 13.4.13 - '@next/swc-win32-x64-msvc': 13.4.13 - transitivePeerDependencies: - - '@babel/core' - - babel-plugin-macros - dev: false - /next@13.4.19(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==} engines: {node: '>=16.8.0'} @@ -7633,7 +7498,6 @@ packages: transitivePeerDependencies: - '@babel/core' - babel-plugin-macros - dev: true /nlcst-to-string@3.1.1: resolution: {integrity: sha512-63mVyqaqt0cmn2VcI2aH6kxe1rLAmSROqHMA0i4qqg1tidkfExgpb0FGMikMCn86mw5dFtBtEANfmSSK7TjNHw==} diff --git a/upgrade/package.json b/upgrade/package.json index 907ad61377..7e3c9d5f42 100644 --- a/upgrade/package.json +++ b/upgrade/package.json @@ -28,7 +28,7 @@ "clsx": "^1.2.1", "gitdiff-parser": "^0.3.1", "lucide-react": "^0.263.1", - "next": "^13.4.13", + "next": "^13.4.19", "react": "18.2.0", "react-diff-view": "^3.0.3", "react-dom": "18.2.0", From 2e953da0e11d61bc7ffbb9198f1818b0a30d2cfc Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Sun, 27 Aug 2023 21:57:48 +0200 Subject: [PATCH 48/71] fix next-step log --- cli/src/helpers/logNextSteps.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/src/helpers/logNextSteps.ts b/cli/src/helpers/logNextSteps.ts index b75dbc1699..66f607e470 100644 --- a/cli/src/helpers/logNextSteps.ts +++ b/cli/src/helpers/logNextSteps.ts @@ -28,7 +28,11 @@ export const logNextSteps = async ({ } if (packages?.prisma.inUse || packages?.drizzle.inUse) { - logger.info(` ${pkgManager === "npm" ? "npx" : pkgManager} db:push`); + if (["npm", "bun"].includes(pkgManager)) { + logger.info(` ${pkgManager} run db:push`); + } else { + logger.info(` ${pkgManager} db:push`); + } } if (["npm", "bun"].includes(pkgManager)) { From 429a77a45c8e2d3a26b56ae87394037910fd6485 Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Mon, 28 Aug 2023 23:25:35 +0200 Subject: [PATCH 49/71] exit gracefully if prisma and drizzle are selected --- cli/src/cli/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 29c5549302..693bd65b27 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -161,13 +161,13 @@ export const runCli = async (): Promise => { if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth"); if (cliResults.flags.prisma && cliResults.flags.drizzle) { - console.warn( - "Incompatible combination Prisma + Drizzle. Falling back to Prisma only." - ); - cliResults.flags.drizzle = false; - cliResults.packages = cliResults.packages.filter( - (pkg) => pkg !== "drizzle" + // We test a matrix of all possible combination of packages in CI. Checking for impossible + // combinations here and exiting gracefully is easier than changing the CI matrix to exclude + // invalid combinations. We are using an "OK" exit code so CI continues with the next combination. + logger.warn( + "Incompatible combination Prisma + Drizzle. Exiting." ); + process.exit(0); } return cliResults; From 7193a1f8ac4423400c7e576face8fb91c83d8a8f Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:02:19 +0200 Subject: [PATCH 50/71] test if --- .github/workflows/e2e.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8e3b93ef4c..0ca79bb592 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,6 +31,12 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: + - name: Check valid matrix + if: ${{ matrix..prisma == "true" && matrix..drizzle == "true" }} + run: | + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + - uses: actions/checkout@v3 with: fetch-depth: 0 From 1d30d53be3c66c3a38cb8a7ade8400f05fec0ff1 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:05:32 +0200 Subject: [PATCH 51/71] ? --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 0ca79bb592..8bccdc143b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -32,7 +32,7 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - name: Check valid matrix - if: ${{ matrix..prisma == "true" && matrix..drizzle == "true" }} + if: ${{ matrix..prisma == "true" }} && ${{ matrix..drizzle == "true" }} run: | gh run cancel ${{ github.run_id }} gh run watch ${{ github.run_id }} From 503fcab258f1f78dd1e6aea3f5db19fe603f9919 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:05:42 +0200 Subject: [PATCH 52/71] Update e2e.yml --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 8bccdc143b..b8145fbbef 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -32,7 +32,7 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - name: Check valid matrix - if: ${{ matrix..prisma == "true" }} && ${{ matrix..drizzle == "true" }} + if: ${{ matrix..prisma == "true" }} && ${{ matrix.drizzle == "true" }} run: | gh run cancel ${{ github.run_id }} gh run watch ${{ github.run_id }} From d55ead4e3fe53a5433046f56b59fdc7a568236c2 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:06:43 +0200 Subject: [PATCH 53/71] syntax --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b8145fbbef..c6a8d63e2e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -32,7 +32,7 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - name: Check valid matrix - if: ${{ matrix..prisma == "true" }} && ${{ matrix.drizzle == "true" }} + if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} run: | gh run cancel ${{ github.run_id }} gh run watch ${{ github.run_id }} From ac8ee8069692a59d197ed8ec0b75eb427bb0aac0 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:09:40 +0200 Subject: [PATCH 54/71] ?? --- .github/workflows/e2e.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c6a8d63e2e..d47be3ffb8 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,11 +31,11 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - - name: Check valid matrix - if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} - run: | - gh run cancel ${{ github.run_id }} - gh run watch ${{ github.run_id }} + # - name: Check valid matrix + # if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} + # run: | + # gh run cancel ${{ github.run_id }} + # gh run watch ${{ github.run_id }} - uses: actions/checkout@v3 with: From 83dce062f06b71a121d6e266a18b62b317b8584d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:10:41 +0200 Subject: [PATCH 55/71] bruh?? --- .github/workflows/e2e.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d47be3ffb8..d470d7154e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,16 +31,16 @@ jobs: name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}}" steps: - # - name: Check valid matrix - # if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} - # run: | - # gh run cancel ${{ github.run_id }} - # gh run watch ${{ github.run_id }} - - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Check valid matrix + if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} + run: | + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + - name: Install Node.js uses: actions/setup-node@v3 with: From 80714f2e5ec92f6451871b208b8b359b6abd452a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:11:56 +0200 Subject: [PATCH 56/71] yaml is fucked --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d470d7154e..81aa34d279 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,7 +36,7 @@ jobs: fetch-depth: 0 - name: Check valid matrix - if: ${{ matrix.prisma == "true" }} && ${{ matrix.drizzle == "true" }} + if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} run: | gh run cancel ${{ github.run_id }} gh run watch ${{ github.run_id }} From 4723e20993ec0d9e16dbba6592e63eb6b23735b3 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:13:07 +0200 Subject: [PATCH 57/71] Update e2e.yml --- .github/workflows/e2e.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 81aa34d279..66212d3c36 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -38,8 +38,10 @@ jobs: - name: Check valid matrix if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} run: | - gh run cancel ${{ github.run_id }} - gh run watch ${{ github.run_id }} + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + env: + GH_TOKEN: ${{ github.token }} - name: Install Node.js uses: actions/setup-node@v3 From f22f59c0b4d75fc226e76102ac9cc7a6613a11ae Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:18:59 +0200 Subject: [PATCH 58/71] this kinda suck --- .github/workflows/e2e.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 66212d3c36..5e8d18b3c3 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,30 +36,32 @@ jobs: fetch-depth: 0 - name: Check valid matrix - if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} + id: matrix-valid + # if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} run: | - gh run cancel ${{ github.run_id }} - gh run watch ${{ github.run_id }} - env: - GH_TOKEN: ${{ github.token }} + echo "continue=${{ matrix.prisma == 'true' && matrix.drizzle == 'true' }}" >> $GITHUB_OUTPUT - name: Install Node.js + if: ${{ steps.matrix-valid.outputs.continue == 'true' }}  uses: actions/setup-node@v3 with: node-version: 18 - uses: pnpm/action-setup@v2.2.4 + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} name: Install pnpm id: pnpm-install with: run_install: false - name: Get pnpm store directory + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT - uses: actions/cache@v3 + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} name: Setup pnpm cache with: path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} @@ -68,14 +70,19 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Install dependencies + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} run: pnpm install - run: pnpm turbo --filter=create-t3-app build + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} + # has to be scaffolded outside the CLI project so that no lint/tsconfig are leaking # through. this way it ensures that it is the app's configs that are being used # FIXME: this is a bit hacky, would rather have --packages=trpc,tailwind,... but not sure how to setup the matrix for that - run: cd cli && pnpm start ../../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}} --noGit --CI --trpc=${{ matrix.trpc }} --tailwind=${{ matrix.tailwind }} --nextAuth=${{ matrix.nextAuth }} --prisma=${{ matrix.prisma }} --drizzle=${{ matrix.drizzle }} + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} - run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.drizzle}} && pnpm build + if: ${{ steps.matrix-valid.outputs.continue == 'true' }} env: NEXTAUTH_SECRET: foo From 29502d84c7e74f2a70bbc28b7a7743b6caf9a163 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:20:25 +0200 Subject: [PATCH 59/71] fix expr --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5e8d18b3c3..5566d365c4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -39,7 +39,7 @@ jobs: id: matrix-valid # if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} run: | - echo "continue=${{ matrix.prisma == 'true' && matrix.drizzle == 'true' }}" >> $GITHUB_OUTPUT + echo "continue=${{ matrix.prisma == 'false' || matrix.drizzle == 'false' }}" >> $GITHUB_OUTPUT - name: Install Node.js if: ${{ steps.matrix-valid.outputs.continue == 'true' }}  From fd4ed679850aee197556349f2e87f8f56c485d2a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 1 Sep 2023 20:25:05 +0200 Subject: [PATCH 60/71] Update e2e.yml --- .github/workflows/e2e.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5566d365c4..fc6dc47b07 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -37,7 +37,6 @@ jobs: - name: Check valid matrix id: matrix-valid - # if: ${{ matrix.prisma == 'true' }} && ${{ matrix.drizzle == 'true' }} run: | echo "continue=${{ matrix.prisma == 'false' || matrix.drizzle == 'false' }}" >> $GITHUB_OUTPUT From 23f1774422522646e5a818692ece38707b53758f Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Fri, 1 Sep 2023 20:26:38 +0200 Subject: [PATCH 61/71] format --- cli/src/cli/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cli/src/cli/index.ts b/cli/src/cli/index.ts index 693bd65b27..8f07b9a6d2 100644 --- a/cli/src/cli/index.ts +++ b/cli/src/cli/index.ts @@ -164,9 +164,7 @@ export const runCli = async (): Promise => { // We test a matrix of all possible combination of packages in CI. Checking for impossible // combinations here and exiting gracefully is easier than changing the CI matrix to exclude // invalid combinations. We are using an "OK" exit code so CI continues with the next combination. - logger.warn( - "Incompatible combination Prisma + Drizzle. Exiting." - ); + logger.warn("Incompatible combination Prisma + Drizzle. Exiting."); process.exit(0); } From 93a1d2a40ea5626a785093d39dc7d559c8b10b5c Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Sat, 2 Sep 2023 22:59:36 +0200 Subject: [PATCH 62/71] fix schema location in drizzle config --- cli/template/extras/config/drizzle.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index adc8c4de1b..91aca7b926 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -6,7 +6,7 @@ import { env } from "~/env.mjs"; dotenv.config(); export default { - schema: "./schema", + schema: "./src/server/db/schema.ts", driver: "mysql2", dbCredentials: { connectionString: env.DATABASE_URL, From d260df87e4e7c310cd4b2dfd89c19c52ec357faa Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Tue, 5 Sep 2023 22:18:26 +0200 Subject: [PATCH 63/71] fix session relation --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index 9be03f2223..ee873bd609 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -92,7 +92,7 @@ export const sessions = mysqlTable( ); export const sessionsRelations = relations(sessions, ({ one }) => ({ - user: one(users), + user: one(users, { fields: [sessions.userId], references: [users.id] }), })); export const verificationTokens = mysqlTable( From 6e8dd513b640e5170a730cdb775e8d64f9d3071a Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Tue, 5 Sep 2023 22:20:34 +0200 Subject: [PATCH 64/71] fix env for drizzle-kit --- cli/src/installers/drizzle.ts | 2 +- cli/template/extras/config/drizzle.config.ts | 3 --- cli/template/extras/src/env/with-auth-db.mjs | 4 +++- cli/template/extras/src/env/with-auth.mjs | 4 +++- cli/template/extras/src/env/with-db.mjs | 4 +++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 926d370fc3..9c3f1d3032 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -52,7 +52,7 @@ export const drizzleInstaller: Installer = ({ const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; packageJsonContent.scripts = { ...packageJsonContent.scripts, - "db:push": "drizzle-kit push:mysql", + "db:push": "dotenv drizzle-kit push:mysql", }; fs.copySync(configFile, configDest); diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index 91aca7b926..17870d08f4 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -1,10 +1,7 @@ -import * as dotenv from "dotenv"; import { type Config } from "drizzle-kit"; import { env } from "~/env.mjs"; -dotenv.config(); - export default { schema: "./src/server/db/schema.ts", driver: "mysql2", diff --git a/cli/template/extras/src/env/with-auth-db.mjs b/cli/template/extras/src/env/with-auth-db.mjs index 58bc43a153..5363637a3a 100644 --- a/cli/template/extras/src/env/with-auth-db.mjs +++ b/cli/template/extras/src/env/with-auth-db.mjs @@ -8,7 +8,9 @@ export const env = createEnv({ */ server: { DATABASE_URL: z.string().url(), - NODE_ENV: z.enum(["development", "test", "production"]), + NODE_ENV: z + .enum(["development", "test", "production"]) + .default("development"), NEXTAUTH_SECRET: process.env.NODE_ENV === "production" ? z.string().min(1) diff --git a/cli/template/extras/src/env/with-auth.mjs b/cli/template/extras/src/env/with-auth.mjs index 71808934f2..da17aef134 100644 --- a/cli/template/extras/src/env/with-auth.mjs +++ b/cli/template/extras/src/env/with-auth.mjs @@ -7,7 +7,9 @@ export const env = createEnv({ * isn't built with invalid env vars. */ server: { - NODE_ENV: z.enum(["development", "test", "production"]), + NODE_ENV: z + .enum(["development", "test", "production"]) + .default("development"), NEXTAUTH_SECRET: process.env.NODE_ENV === "production" ? z.string().min(1) diff --git a/cli/template/extras/src/env/with-db.mjs b/cli/template/extras/src/env/with-db.mjs index 3bc39f515e..d96eb5ce6c 100644 --- a/cli/template/extras/src/env/with-db.mjs +++ b/cli/template/extras/src/env/with-db.mjs @@ -8,7 +8,9 @@ export const env = createEnv({ */ server: { DATABASE_URL: z.string().url(), - NODE_ENV: z.enum(["development", "test", "production"]), + NODE_ENV: z + .enum(["development", "test", "production"]) + .default("development"), }, /** From 46d10777303b5057632af19652eccc1f868b20f2 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Tue, 5 Sep 2023 22:28:15 +0200 Subject: [PATCH 65/71] table filter for drizzle-kit --- cli/src/installers/drizzle.ts | 6 ++++++ cli/template/extras/config/drizzle.config.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 9c3f1d3032..26182aecdd 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -42,6 +42,11 @@ export const drizzleInstaller: Installer = ({ "project1_${name}", `${scopedAppName}_\${name}` ); + let configContent = fs.readFileSync(configFile, "utf-8"); + configContent = configContent.replace( + "project1_*", + `${scopedAppName}_*` + ); const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); const clientDest = path.join(projectDir, "src/server/db/index.ts"); @@ -58,6 +63,7 @@ export const drizzleInstaller: Installer = ({ fs.copySync(configFile, configDest); fs.mkdirSync(path.dirname(schemaDest), { recursive: true }); fs.writeFileSync(schemaDest, schemaContent); + fs.writeFileSync(configDest, configContent); fs.copySync(clientSrc, clientDest); fs.writeJSONSync(packageJsonPath, packageJsonContent, { spaces: 2, diff --git a/cli/template/extras/config/drizzle.config.ts b/cli/template/extras/config/drizzle.config.ts index 17870d08f4..aaef4720f4 100644 --- a/cli/template/extras/config/drizzle.config.ts +++ b/cli/template/extras/config/drizzle.config.ts @@ -8,4 +8,5 @@ export default { dbCredentials: { connectionString: env.DATABASE_URL, }, + tablesFilter: ["project1_*"], } satisfies Config; From 3b365f1c7e75e3552b011bee91e6e523edd60648 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Tue, 5 Sep 2023 22:31:24 +0200 Subject: [PATCH 66/71] format --- cli/src/installers/drizzle.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 26182aecdd..858f8e5d47 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -43,10 +43,7 @@ export const drizzleInstaller: Installer = ({ `${scopedAppName}_\${name}` ); let configContent = fs.readFileSync(configFile, "utf-8"); - configContent = configContent.replace( - "project1_*", - `${scopedAppName}_*` - ); + configContent = configContent.replace("project1_*", `${scopedAppName}_*`); const clientSrc = path.join(extrasDir, "src/server/db/index-drizzle.ts"); const clientDest = path.join(projectDir, "src/server/db/index.ts"); From a2eecac6741eaeb2f39625c8e6548a4993708331 Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Thu, 7 Sep 2023 00:47:54 +0200 Subject: [PATCH 67/71] add dotenv-cli so db:push works w/o global dotenv --- cli/src/installers/dependencyVersionMap.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index 6b94c4b8da..c80baf6f90 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -16,6 +16,7 @@ export const dependencyVersionMap = { "drizzle-orm": "^0.28.5", "drizzle-kit": "^0.19.13", dotenv: "^16.1.4", + "dotenv-cli": "^7.3.0", "@planetscale/database": "^1.11.0", // TailwindCSS From 3fe2b413486a9abeaf50e8e192e6b1d056cd2ac3 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Thu, 7 Sep 2023 09:47:12 +0200 Subject: [PATCH 68/71] rm other dotenv dep and install the cli one --- cli/src/installers/dependencyVersionMap.ts | 1 - cli/src/installers/drizzle.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/src/installers/dependencyVersionMap.ts b/cli/src/installers/dependencyVersionMap.ts index c80baf6f90..11dc1f3877 100644 --- a/cli/src/installers/dependencyVersionMap.ts +++ b/cli/src/installers/dependencyVersionMap.ts @@ -15,7 +15,6 @@ export const dependencyVersionMap = { // Drizzle "drizzle-orm": "^0.28.5", "drizzle-kit": "^0.19.13", - dotenv: "^16.1.4", "dotenv-cli": "^7.3.0", "@planetscale/database": "^1.11.0", diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index 858f8e5d47..f1de68e5d2 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -13,7 +13,7 @@ export const drizzleInstaller: Installer = ({ }) => { addPackageDependency({ projectDir, - dependencies: ["drizzle-kit", "dotenv"], + dependencies: ["drizzle-kit", "dotenv-cli"], devMode: true, }); addPackageDependency({ From 22250c1f48f6eeb0c5680c3f7764c45a2f297ff6 Mon Sep 17 00:00:00 2001 From: c-ehrlich Date: Thu, 7 Sep 2023 21:47:43 +0200 Subject: [PATCH 69/71] add note about drizzle to first steps docs --- www/src/pages/en/usage/first-steps.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/www/src/pages/en/usage/first-steps.md b/www/src/pages/en/usage/first-steps.md index b88edf1fb7..c28fd5b8fa 100644 --- a/www/src/pages/en/usage/first-steps.md +++ b/www/src/pages/en/usage/first-steps.md @@ -9,8 +9,14 @@ You just scaffolded a new T3 App and are ready to go. Here is the bare minimum t ## Database +### Prisma + If your app includes Prisma, make sure to run `npx prisma db push` from the root directory of your app. This command will sync your Prisma schema with your database and will generate the TypeScript types for the Prisma Client based on your schema. Note that you need to [restart the TypeScript server](https://tinytip.co/tips/vscode-restart-ts/) after doing this so that it can detect the generated types. +### Drizzle + +If your app includes Drizzle, check the `.env` file for instructions on how to construct your `DATABASE_URL` env variable. Once your env file is ready, run `pnpm db:push` (or the equivalent for other package managers) to push your schema. + ## Authentication If your app includes NextAuth.js, we get you started with the `DiscordProvider`. This is one of the simplest providers that NextAuth.js offers, but it still requires a bit of initial setup on your part. From 260f2a5c7b95ca85ebf0ffdfde66a17edcd42d25 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Mon, 11 Sep 2023 08:52:13 +0200 Subject: [PATCH 70/71] update links --- .changeset/fast-teachers-explain.md | 2 +- www/src/pages/en/faq.mdx | 2 +- www/src/pages/pl/faq.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/fast-teachers-explain.md b/.changeset/fast-teachers-explain.md index 8c7d8124a1..665327447f 100644 --- a/.changeset/fast-teachers-explain.md +++ b/.changeset/fast-teachers-explain.md @@ -4,7 +4,7 @@ feat: add drizzle -This release adds a new option to use [`drizzle-orm`](https://orm.drizzle.team/) as an alternative to Prisma. +This release adds a new option to use [`drizzle-orm`](https://orm.drizzle.team/docs/overview) as an alternative to Prisma. To make the different ORM options as similar as possible, some minor changes has also been made to the Prisma installer: diff --git a/www/src/pages/en/faq.mdx b/www/src/pages/en/faq.mdx index 9ada523637..1271158411 100644 --- a/www/src/pages/en/faq.mdx +++ b/www/src/pages/en/faq.mdx @@ -21,7 +21,7 @@ If you are not familiar with the different technologies used in this project, pl - [Prisma](https://prisma.io) - [Tailwind CSS](https://tailwindcss.com) - [tRPC](https://trpc.io) -- [Drizzle](https://drizzle.team/) +- [Drizzle](https://orm.drizzle.team/docs/overview) ## How do I keep my app up to date? diff --git a/www/src/pages/pl/faq.md b/www/src/pages/pl/faq.md index a0b62d95d3..735891ecd4 100644 --- a/www/src/pages/pl/faq.md +++ b/www/src/pages/pl/faq.md @@ -18,7 +18,7 @@ Jeżeli nie znasz poszczególnych technologi użytych w projekcie, skorzystaj z - [Prisma](https://prisma.io) - [Tailwind CSS](https://tailwindcss.com) - [tRPC](https://trpc.io) -- [Drizzle](https://drizzle.team/) +- [Drizzle](https://orm.drizzle.team/docs/overview) ## Jak sprawić, by aplikacja była ciągle aktualna? From 4e8fe9f646b3fe33f31bfac6755f13392d9ab246 Mon Sep 17 00:00:00 2001 From: juliusmarminge Date: Mon, 11 Sep 2023 08:53:48 +0200 Subject: [PATCH 71/71] use bigint over serial --- cli/template/extras/src/server/db/drizzle-schema-auth.ts | 4 ++-- cli/template/extras/src/server/db/drizzle-schema-base.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/template/extras/src/server/db/drizzle-schema-auth.ts b/cli/template/extras/src/server/db/drizzle-schema-auth.ts index ee873bd609..ee154f7e78 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-auth.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-auth.ts @@ -1,10 +1,10 @@ import { relations, sql } from "drizzle-orm"; import { + bigint, index, int, mysqlTableCreator, primaryKey, - serial, text, timestamp, uniqueIndex, @@ -23,7 +23,7 @@ export const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); export const example = mysqlTable( "example", { - id: serial("id").primaryKey(), + id: bigint("id", { mode: "number" }).primaryKey().autoincrement(), name: varchar("name", { length: 256 }), createdAt: timestamp("created_at") .default(sql`CURRENT_TIMESTAMP`) diff --git a/cli/template/extras/src/server/db/drizzle-schema-base.ts b/cli/template/extras/src/server/db/drizzle-schema-base.ts index 05f708c28d..bf0360bc6a 100644 --- a/cli/template/extras/src/server/db/drizzle-schema-base.ts +++ b/cli/template/extras/src/server/db/drizzle-schema-base.ts @@ -3,8 +3,8 @@ import { sql } from "drizzle-orm"; import { + bigint, mysqlTableCreator, - serial, timestamp, uniqueIndex, varchar, @@ -21,7 +21,7 @@ export const mysqlTable = mysqlTableCreator((name) => `project1_${name}`); export const example = mysqlTable( "example", { - id: serial("id").primaryKey(), + id: bigint("id", { mode: "number" }).primaryKey().autoincrement(), name: varchar("name", { length: 256 }), createdAt: timestamp("created_at") .default(sql`CURRENT_TIMESTAMP`)