Skip to content

Commit

Permalink
feat: add drizzle (#1461)
Browse files Browse the repository at this point in the history
Co-authored-by: c-ehrlich <[email protected]>
Co-authored-by: Midas <[email protected]>
Co-authored-by: wiktrek <[email protected]>
  • Loading branch information
4 people authored Sep 11, 2023
1 parent db6a204 commit 8034db0
Show file tree
Hide file tree
Showing 50 changed files with 1,218 additions and 457 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-pants-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

refactor: swap inquirer for clack
22 changes: 22 additions & 0 deletions .changeset/fast-teachers-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"create-t3-app": minor
---

feat: add drizzle

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:

- 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.db.query.example.findMany()
}),
```

You cannot choose the two options in the same app.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,40 @@ 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:
fetch-depth: 0

- name: Check valid matrix
id: matrix-valid
run: |
echo "continue=${{ matrix.prisma == 'false' || matrix.drizzle == 'false' }}" >> $GITHUB_OUTPUT
- name: Install Node.js
if: ${{ steps.matrix-valid.outputs.continue == 'true' }} 
uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/[email protected]
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 }}
Expand All @@ -59,14 +69,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 }} --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 }}
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

Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"mdx.experimentalLanguageServer": true,
"[astro]": {
"editor.defaultFormatter": "astro-build.astro-vscode"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
}
}
24 changes: 15 additions & 9 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,36 @@
"pub:release": "pnpm build && npm publish"
},
"dependencies": {
"@clack/core": "^0.3.2",
"@clack/prompts": "^0.6.3",
"@ianvs/prettier-plugin-sort-imports": "^4.1.0",
"chalk": "5.2.0",
"commander": "^10.0.0",
"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"
},
"devDependencies": {
"@prisma/client": "^4.14.0",
"@auth/drizzle-adapter": "^0.3.2",
"@next-auth/prisma-adapter": "^1.0.7",
"@planetscale/database": "^1.11.0",
"@prisma/client": "^5.1.1",
"@t3-oss/env-nextjs": "^0.6.0",
"@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",
"@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",
"next": "^13.4.1",
"next-auth": "^4.22.1",
"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",
Expand Down
Loading

2 comments on commit 8034db0

@vercel
Copy link

@vercel vercel bot commented on 8034db0 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 8034db0 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

t3-upgrade – ./upgrade

t3-upgrade-git-next-t3-oss.vercel.app
t3-upgrade.vercel.app
t3-upgrade-t3-oss.vercel.app

Please sign in to comment.