1
0
mirror of synced 2026-02-04 12:08:33 -05:00

Compare commits

..

49 Commits

Author SHA1 Message Date
github-actions[bot]
0ebdf3bc93 Version Packages (beta) (#3929)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-10-28 15:27:06 +08:00
Aleksandra
1b798d9a03 Export enhancePrisma from the server entry point (#3928)
* Export enhancePrisma from the server entry point

* Changeset

* Update pnpm lock
2022-10-27 10:04:31 -04:00
Blitz.js Bot
758ccbbbe5 (meta) added @joneskj55 as contributor 2022-10-25 06:38:44 -04:00
github-actions[bot]
d73b1d76ab Version Packages (beta) (#3916)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-10-25 18:32:26 +08:00
Dillon Raphael
78fd5c489b Fix Blitz Install (#3909) 2022-10-24 21:50:54 -04:00
Aleksandra
60de057477 Fix reset token being undefined when passed to the resetPassword mutation (#3922) 2022-10-22 11:23:51 +08:00
Siddharth Suresh
0a8b0cb350 Custom Server TS error (#3888) 2022-10-20 14:56:40 +08:00
Aleksandra
5476139375 Remove unnecessary as number assertions from new app templates (#3915) 2022-10-19 16:25:35 +08:00
github-actions[bot]
81dd346c85 Version Packages (beta) (#3907)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-10-19 14:56:44 +08:00
Aleksandra
6f4349896f Fix 'ambiguous class detected' errors (#3912) 2022-10-19 13:44:33 +08:00
Aleksandra
a6e81f156b Add BlitzLogger plugin and allow customizing logging (#3886) 2022-10-18 15:50:17 +08:00
Aleksandra
4e26ae21bc Upgrade eslint-config-next in new app templates to fix linting issues on blitz build (#3910) 2022-10-18 14:54:47 +08:00
Blitz.js Bot
70ca39e059 (meta) added @janvennemann as contributor 2022-10-17 04:06:03 -04:00
Jan Vennemann
7b63f0f1f2 fix(rpc): allow return undefined in setQueryData updater function (#3898)
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-10-17 16:05:57 +08:00
Siddharth Suresh
2e5d7ae40c Upgrade CI Syntax (#3906) 2022-10-17 15:33:36 +08:00
github-actions[bot]
67de028732 Version Packages (beta) (#3896)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-10-13 14:02:17 +08:00
Siddharth Suresh
f39ba1ff13 #3748 Add custom template option back to blitz generate command (#3866) 2022-10-12 11:46:24 -04:00
Blitz.js Bot
149b999f67 (meta) added @oloost as contributor 2022-10-12 06:13:22 -04:00
Aleksandra
3a602b613b Fix missing blitz/installer dependency in recipes (#3895) 2022-10-12 18:11:12 +08:00
github-actions[bot]
58bb38f809 Version Packages (beta) (#3893)
* Version Packages (beta)

* Fix version

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-10-11 17:48:40 +08:00
Aleksandra
1476a577bb Update PULL_REQUEST_TEMPLATE.md (#3878) 2022-10-11 17:32:21 +08:00
github-actions[bot]
4e3c25d9a0 Version Packages (beta) (#3839)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-10-11 16:24:43 +08:00
Estevan Jantsk
2ade7268e2 Add blitz export command (#3885)
Co-authored-by: Fran Zekan <zekan.fran369@gmail.com>
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-10-11 16:18:54 +08:00
Fran Zekan
aa34661fac Fix queryKeyGeneration when using invalidateQuery (#3728)
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-10-11 16:01:47 +08:00
Siddharth Suresh
d98e4bac4e Migrate blitz routes command (#3890) 2022-10-11 15:50:30 +08:00
Isuru Maldeniya
0473020555 update prisma-ast version in blitz generator package (#3882)
Co-authored-by: Isuru Maldeniya <isuru.m@synergentl.com>
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-10-04 18:30:33 +08:00
Jannik Schmidtke
8a88dec873 Add a .vscode/settings.json file to specify a TypeScript version (#3876) 2022-10-04 15:35:03 +08:00
Fran Zekan
d6717b9d3c Try to load prisma.schema path from pkg json (#3874)
* Try to load prisma.schema path from pkg json
2022-10-03 13:02:41 -04:00
Daniel Oltmanns
eb970f7bbc fix detecting blitz.config.(ts|js) config file (#3701)
* fix detecting blit.config.(ts|js) config file
2022-10-03 12:41:57 -04:00
Dillon Raphael
8e0c9d76b5 Migrate recipes (#3784) 2022-10-03 09:21:45 -04:00
portalninja
bd09db7533 remove views property from Session's publicData in types.ts file (#3872)
* fix: remove views from public Session data

* add changeset

* Update .changeset/strong-keys-lie.md

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-10-03 11:29:20 +08:00
João Jesus
83281a8469 remove {} from single values in the eslint config in package.json (#3877)
* refactor(js-templates): remove {} from single values inside package.json

* Add changeset

Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-10-03 11:05:13 +08:00
Siddharth Suresh
15d22af24a Migrate console (#3863)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-09-29 22:22:07 +02:00
Siddharth Suresh
1c3106eacf (meta) add @siddhsuresh as maintainer (#3868) 2022-09-29 16:47:09 +02:00
Fran Zekan
af58e2b239 CLI Version check fixes (#3675)
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-09-29 08:59:40 +02:00
Dillon Raphael
430f6ec782 Only generate the prisma client if it's not found (#3855) 2022-09-29 08:34:40 +02:00
Aleksandra
e2c18895da Add client testing utilities and index.test.tsx back to toolkit (#3857) 2022-09-28 16:38:58 -04:00
Aleksandra
3b3c245fb1 Update sponsors list (#3865) 2022-09-26 10:37:56 +02:00
Siddharth Suresh
7b00c17376 Add CI action that checks if changeset was added (#3850) 2022-09-23 14:22:12 +02:00
Dillon Raphael
b43c1a81cc Remove random user git config when generating a new project (#3852) 2022-09-22 12:49:48 +02:00
Aleksandra
1742eb45db Use prefetchInfiniteQuery from @tanstack/react-query for prefetching infinite Blitz queries (#3847)
* Use prefetchInfiniteQuery from @tanstack/react-query for prefetching infinite Blitz queries
2022-09-19 15:23:57 -04:00
Aleksandra
824a9b5e29 Update generator templates to stop breaking no-floating-promises rule (#3848)
* Update generator templates to stop breaking no-floating-promises rule
2022-09-19 15:07:42 -04:00
Aleksandra
9db6c88555 Fix help CLI command not working correctly (#3849)
* Fix help CLI command not working correctly
2022-09-19 14:57:53 -04:00
Jan Wilhelm
25f4526f7e Add API Route handler to the middleware stack (#3830)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-09-19 10:41:42 +02:00
Dillon Raphael
9fe0cc5468 Throw redirect errors when component has mounted in blitz-auth (#3842)
* Throw redirect errors when component has mounted

* Create heavy-cobras-own.md

* clean up useEffect

* Add mounted check for AuthenticationError

* remove clean up
2022-09-16 16:33:34 -04:00
Dillon Raphael
0edeaa37a3 Update regex for wildcard blitz route in webpack config (#3843)
* update regex for wildcard blitz route in webpack config

* Create itchy-spoons-tan.md

* fix regex

* Update itchy-spoons-tan.md
2022-09-16 14:05:31 -04:00
Estevan Jantsk
bf4aaf1de6 move useCurrentUser from core/hooks to users/hooks (#3831)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
2022-09-15 15:56:09 +02:00
Siddharth Suresh
b3b4c21501 convert invokeWithMiddleware to resolver call in codemod (#3764) 2022-09-14 14:38:04 -04:00
Dillon Raphael
757789c43b CI Fixes (#3834) 2022-09-14 09:42:27 -04:00
358 changed files with 11648 additions and 683 deletions

View File

@@ -3689,7 +3689,9 @@
"profile": "https://github.com/siddhsuresh",
"contributions": [
"doc",
"code"
"code",
"test",
"maintenance"
]
},
{
@@ -3712,6 +3714,34 @@
"contributions": [
"doc"
]
},
{
"login": "oloost",
"name": "oloost",
"avatar_url": "https://avatars.githubusercontent.com/u/72395941?v=4",
"profile": "https://github.com/oloost",
"contributions": [
"doc"
]
},
{
"login": "janvennemann",
"name": "Jan Vennemann",
"avatar_url": "https://avatars.githubusercontent.com/u/1406024?v=4",
"profile": "https://github.com/janvennemann",
"contributions": [
"doc",
"code"
]
},
{
"login": "joneskj55",
"name": "Kevin Jones",
"avatar_url": "https://avatars.githubusercontent.com/u/20748598?v=4",
"profile": "https://kevinjones.engineer",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Update prisma-ast dependency to prevent Blitz generator from failing when Prisma keywords are used as model names

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix `blitz --help` CLI command not being found

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Remove unnecessary `as number` assertions from new app templates

View File

@@ -2,21 +2,10 @@
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [
[
"blitz"
],
[
"@blitzjs/*"
]
],
"fixed": [["blitz"], ["@blitzjs/*"]],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"web",
"test-*",
"toolkit-*"
]
"ignore": ["web", "test-*", "toolkit-*", "@blitzjs/recipe-*"]
}

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Fix `no-floating-promises` lint errors after generating pages with Blitz generator by adding `await` to `router.push` calls in the templates

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Load schema.prisma path from `package.json` instead of assuming it's `db/schema.prisma`

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Add `blitz routes` CLI command back to toolkit

View File

@@ -0,0 +1,11 @@
---
"blitz": patch
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
"@blitzjs/codemod": patch
"@blitzjs/config": patch
"@blitzjs/generator": patch
---
Fix release

View File

@@ -0,0 +1,6 @@
---
"blitz": patch
"@blitzjs/next": patch
---
Add BlitzLogger plugin and allow customizing logging

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/next": patch
---
Fix prefetching infinite Blitz queries.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Move `useCurrentUser` hook from `core/hooks` to `users/hooks` folder

View File

@@ -0,0 +1,7 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
"blitz": patch
---
Fix auth related React hydration errors by not redirecting until after component mount.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Remove the random user (noop@blitzjs.com) & use user's default git account when commiting a new generated blitz project.

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Add a global Blitz version check when generating a new Blitz project to ensure users use the latest Blitz.

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix Blitz Install issue that gets stuck on "Generating file diff"

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix `blitz install` not working due to missing `blitz/installer` dependency

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Add `blitz export` CLI command to toolkit

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Allow for custom page extensions for the wildcard blitz route. For example [...blitz].api.ts. For more information vist https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/rpc": patch
---
Allow the updater function in setQueryData to return undefined to match react-query typings

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Fix reset token being undefined when passed to the resetPassword mutation

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix "Ambiguous class detected" errors reported by SuperJson by removing duplicated export from errors.ts file

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/config": patch
"@blitzjs/generator": patch
---
Upgrade eslint-config-next in new app templates to fix linting issues on blitz build

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix Custom Server TS error - add `es6` target config to esbuild

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/codemod": patch
---
Unwrap `invokeWithMiddleware` so the query or mutation is called directly when running the codemod

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Only generate the prisma client if it's not found in node_modules when running a blitz cli command.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Fix eslint config in new JavaScript app templates

View File

@@ -20,12 +20,38 @@
"test-no-suspense": "0.0.0",
"test-trailing-slash": "0.0.0",
"test-middleware": "0.0.0",
"test-react-query-utils": "0.0.0"
"test-react-query-utils": "0.0.0",
"toolkit-app-passport": "1.0.1-alpha.16",
"test-get-initial-props": "0.0.0",
"@blitzjs/recipe-base-web": "0.34.0-canary.0",
"@blitzjs/recipe-bulma": "0.34.0-canary.0",
"@blitzjs/recipe-bumbag-ui": "0.34.0-canary.0",
"@blitzjs/recipe-chakra-ui": "0.34.0-canary.0",
"@blitzjs/recipe-emotion": "0.34.0-canary.0",
"@blitzjs/recipe-gh-action-yarn-mariadb": "0.34.0-canary.0",
"@blitzjs/recipe-gh-action-yarn-postgres": "0.34.0-canary.0",
"@blitzjs/recipe-ghost": "0.40.0-canary.9",
"@blitzjs/recipe-graphql": "0.34.0-canary.0",
"@blitzjs/recipe-logrocket": "0.34.0-canary.0",
"@blitzjs/recipe-material-ui": "0.34.0-canary.0",
"@blitzjs/recipe-next-ui": "0.34.0-canary.0",
"@blitzjs/recipe-passenger": "0.34.0-canary.0",
"@blitzjs/recipe-quirrel": "0.34.0-canary.0",
"@blitzjs/recipe-reflexjs": "0.34.0-canary.0",
"@blitzjs/recipe-render": "0.34.0-canary.0",
"@blitzjs/recipe-secureheaders": "0.34.0-canary.0",
"@blitzjs/recipe-stitches": "0.34.0-canary.0",
"@blitzjs/recipe-styled-components": "0.34.0-canary.0",
"@blitzjs/recipe-tailwind": "0.34.0-canary.0",
"@blitzjs/recipe-theme-ui": "0.34.0-canary.0",
"@blitzjs/recipe-vanilla-extract": "0.34.0-canary.0"
},
"changesets": [
"afraid-dancers-juggle",
"big-phones-bow",
"blue-flowers-peel",
"blue-pigs-tan",
"breezy-bees-beg",
"breezy-cameras-double",
"breezy-moose-behave",
"bright-mangos-run",
@@ -35,6 +61,7 @@
"calm-nails-wait",
"calm-tomatoes-drive",
"chilled-carrots-own",
"chilly-nails-nail",
"clean-hats-pump",
"clean-walls-wink",
"clever-radios-lie",
@@ -49,7 +76,9 @@
"dirty-planets-chew",
"early-lamps-itch",
"eleven-humans-sort",
"eleven-lobsters-drop",
"empty-berries-rule",
"empty-pants-search",
"empty-turkeys-wave",
"fair-carrots-guess",
"fair-kangaroos-clean",
@@ -58,6 +87,7 @@
"fast-clocks-push",
"fast-trainers-kneel",
"few-dogs-fetch",
"few-shrimps-leave",
"flat-bees-approve",
"fluffy-mangos-begin",
"fluffy-mice-wash",
@@ -68,6 +98,8 @@
"fuzzy-bees-warn",
"fuzzy-jars-admire",
"gentle-dogs-reply",
"gentle-lions-explode",
"giant-mails-tap",
"gold-horses-punch",
"good-apes-drum",
"good-insects-wink",
@@ -79,19 +111,31 @@
"great-terms-rescue",
"green-papayas-do",
"green-pillows-hammer",
"happy-bees-lick",
"happy-hotels-visit",
"happy-paws-join",
"healthy-rice-shout",
"heavy-apes-judge",
"heavy-cobras-own",
"hip-buttons-dance",
"honest-candles-yawn",
"honest-cherries-push",
"honest-comics-vanish",
"hot-cups-rhyme",
"hot-drinks-approve",
"hungry-baboons-swim",
"hungry-pens-collect",
"itchy-houses-marry",
"itchy-spoons-tan",
"khaki-ducks-cheer",
"kind-walls-suffer",
"late-steaks-give",
"lazy-maps-sort",
"lemon-games-press",
"lemon-pillows-switch",
"lemon-seas-push",
"light-donkeys-double",
"little-pears-ring",
"long-bees-hope",
"long-dancers-jog",
"long-lobsters-drop",
@@ -99,15 +143,18 @@
"lovely-colts-share",
"lucky-cows-try",
"lucky-months-guess",
"lucky-years-turn",
"mean-gorillas-reply",
"modern-cameras-pull",
"modern-ligers-behave",
"moody-bags-walk",
"moody-spoons-rhyme",
"moody-squids-cheer",
"nasty-suns-wash",
"nervous-beds-travel",
"nervous-dolls-rule",
"new-coats-turn",
"new-olives-protect",
"nice-deers-dream",
"nice-starfishes-live",
"nine-birds-confess",
@@ -117,7 +164,9 @@
"ninety-rice-tickle",
"olive-bees-buy",
"olive-feet-rhyme",
"olive-kings-invent",
"olive-sheep-rhyme",
"orange-mirrors-tap",
"orange-zebras-reflect",
"perfect-eyes-repeat",
"perfect-trains-double",
@@ -146,11 +195,13 @@
"shy-olives-hang",
"shy-pumpkins-try",
"silent-colts-reply",
"silent-lies-run",
"silly-apricots-share",
"silly-shoes-agree",
"six-apricots-kick",
"slimy-humans-impress",
"slimy-needles-taste",
"slow-impalas-tap",
"slow-walls-camp",
"slow-walls-poke",
"small-socks-confess",
@@ -163,14 +214,18 @@
"sour-mails-lick",
"spicy-beds-float",
"spotty-dingos-stare",
"spotty-lies-visit",
"spotty-peas-hope",
"spotty-zoos-film",
"stale-jobs-drum",
"strong-apes-reply",
"strong-keys-lie",
"stupid-walls-sell",
"sweet-kiwis-cross",
"swift-drinks-dress",
"tall-meals-learn",
"tame-keys-reply",
"tame-pumpkins-nail",
"tasty-maps-fetch",
"tasty-news-collect",
"ten-hairs-listen",
@@ -178,11 +233,13 @@
"tender-pianos-check",
"thick-parrots-float",
"thirty-countries-build",
"thirty-spies-applaud",
"three-lies-pull",
"tidy-clouds-smoke",
"tough-toes-pull",
"twelve-hornets-sip",
"twelve-lemons-smile",
"twelve-needles-worry",
"twenty-beans-pump",
"two-carpets-rhyme",
"two-eyes-knock",
@@ -194,6 +251,7 @@
"violet-bags-leave",
"violet-lions-help",
"weak-suns-shave",
"wicked-badgers-smoke",
"wicked-ghosts-cough",
"wicked-rings-walk",
"wise-eels-visit",

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Fix `useSession` hook by exporting `enhancePrisma` from the server entry point instead of server

View File

@@ -0,0 +1,6 @@
---
"blitz": patch
"@blitzjs/generator": patch
---
Allow passing custom templates to the `blitz generate` command. Extend the `generate` command with `custom-templates` to provide an easy starting point for users to customize the default templates: `blitz generate custom-templates`.

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/codemod": patch
---
Fix detecting `blitz.config.(ts|js)` config file when running the codemod.

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Add `blitz console` CLI command back to toolkit

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Remove `views` property from `Session.PublicData` in `types.ts` file

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Fix invalidateQuery generating wrong param when no param argument is passed

View File

@@ -0,0 +1,6 @@
---
"@blitzjs/rpc": patch
"blitz": patch
---
Migrate over recipe functionality from legacy framework & expose recipe builder helper functions that find and modify next.config.js, blitz-server & blitz-client.

View File

@@ -0,0 +1,7 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
Add client testing utilities and a sample test to a new blitz app template

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/next": patch
---
Treat API Route handler as a middleware. This allows outer middlewares to completely wrap queries and mutations.

View File

@@ -3,6 +3,11 @@ Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible please:
- Link issue via "Closes #[issue_number]
- Choose & follow the right checklist for the change that you're making:
Please make sure to add a changeset. Run `pnpm changeset` in the root directory to do so.
Then select updated Blitz packages when prompted, and add a short message describing the changes.
The message should be user-facing — explain **what** was changed, not **how**.
Ignore if there are no user-facing changes.
-->
Closes: ?
@@ -11,9 +16,11 @@ Closes: ?
## Bug Checklist
- [ ] Changeset added (run `pnpm changeset` in the root directory)
- [ ] Integration test added (see [test docs](https://blitzjs.com/docs/contributing#running-tests) if needed)
## Feature Checklist
- [ ] Changeset added (run `pnpm changeset` in the root directory)
- [ ] Integration test added (see [test docs](https://blitzjs.com/docs/contributing#running-tests) if needed)
- [ ] Documentation added/updated (submit PR to [blitzjs.com repo `canary` branch](https://github.com/blitz-js/blitzjs.com/tree/canary))
- [ ] Documentation added/updated (submit PR to [blitzjs.com repo `main` branch](https://github.com/blitz-js/blitzjs.com))

26
.github/workflows/changeset_check.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Changeset
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changeset:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changeset') && github.event.pull_request.merged == false }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 16
- name: Check if changeset is added
run: |
npx @changesets/cli@2.12.0 status --since=origin/${GITHUB_BASE_REF}

View File

@@ -127,9 +127,9 @@ jobs:
shell: bash
run: |
cd ./integration-tests
tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring)'
folders=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring)')
echo "::set-output name=folders::$folders"
tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring) | map(select(. != "utils"))'
folders=$(tree -J -d -L 1 | jq -c '.[0].contents | map(.name | tostring) | map(select(. != "utils"))')
echo "folders=$folders" >> $GITHUB_OUTPUT
Integration-Tests:
name: "Integration Test: ${{matrix.folder}} @ ${{ matrix.os }} "
@@ -158,6 +158,10 @@ jobs:
node-version: ${{ matrix.NODE_VERSION }}
cache: "pnpm"
- name: Link Blitz CLI
run: pnpm link ./packages/blitz
shell: bash
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@@ -6,7 +6,7 @@
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
</a>
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-393-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-396-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
@@ -76,6 +76,9 @@ Your financial contributions help ensure Blitz continues to be developed and mai
</a></td>
<td><a aria-label="MeetKai" href="https://meetkai.com/?ref=blitzjs">
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/meetkai.png" width="40px"/>
</a></td>
<td><a aria-label="Simon Lammes" href="https://github.com/simon-lammes">
<img alt="" src="https://avatars.githubusercontent.com/u/46446421?v=4" width="40px"/>
</a></td>
</tr>
</table>
@@ -195,6 +198,14 @@ _Issue triage, pull request triage, community encouragement and moderation, etc_
</sub>
</a>
</td>
<td align="center">
<a href="https://siddharthsuresh.vercel.app/">
<img src="https://avatars.githubusercontent.com/u/83594610?v=4" width="100px;" alt="Siddharth Suresh avatar" /><br />
<sub>
<b>Siddharth Suresh</b>
</sub>
</a>
</td>
</tr>
</table>
<!-- markdownlint-enable -->
@@ -712,11 +723,14 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://chaiwattsw.com/"><img src="https://avatars.githubusercontent.com/u/30198386?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chaiwat Trisuwan</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=chaiwattsw" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=chaiwattsw" title="Code">💻</a></td>
<td align="center"><a href="oltdaniel.eu"><img src="https://avatars.githubusercontent.com/u/53529846?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Oltmanns</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=oltdaniel" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=oltdaniel" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/edrickleong"><img src="https://avatars.githubusercontent.com/u/10529706?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Edrick Leong</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=edrickleong" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=edrickleong" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=edrickleong" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/siddhsuresh"><img src="https://avatars.githubusercontent.com/u/83594610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Siddharth Suresh</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=siddhsuresh" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=siddhsuresh" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/siddhsuresh"><img src="https://avatars.githubusercontent.com/u/83594610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Siddharth Suresh</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=siddhsuresh" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=siddhsuresh" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=siddhsuresh" title="Tests">⚠️</a> <a href="#maintenance-siddhsuresh" title="Maintenance">🚧</a></td>
<td align="center"><a href="http://jins.dev"><img src="https://avatars.githubusercontent.com/u/39466936?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JH.Lee</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=orionmiz" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=orionmiz" title="Tests">⚠️</a> <a href="#maintenance-orionmiz" title="Maintenance">🚧</a> <a href="https://github.com/blitz-js/blitz/commits?author=orionmiz" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/corydeppen"><img src="https://avatars.githubusercontent.com/u/313264?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cory Deppen</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=corydeppen" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/oloost"><img src="https://avatars.githubusercontent.com/u/72395941?v=4?s=100" width="100px;" alt=""/><br /><sub><b>oloost</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=oloost" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/janvennemann"><img src="https://avatars.githubusercontent.com/u/1406024?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Vennemann</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=janvennemann" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=janvennemann" title="Code">💻</a></td>
<td align="center"><a href="https://kevinjones.engineer"><img src="https://avatars.githubusercontent.com/u/20748598?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin Jones</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=joneskj55" title="Documentation">📖</a></td>
</tr>
</table>

View File

@@ -92,8 +92,6 @@ __name__
│ │ ├── components/
│ │ │ ├── Form.tsx
│ │ │ └── LabeledTextField.tsx
│ │ ├── hooks/
│ │ │ └── useCurrentUser.ts
│ │ └── layouts/
│ │ └── Layout.tsx
│ ├── pages/
@@ -103,6 +101,8 @@ __name__
│ │ ├── index.test.tsx
│ │ └── index.tsx
│ └── users/
│ ├── hooks/
│ │ └── useCurrentUser.ts
│ └── queries/
│ └── getCurrentUser.ts
├── db/

View File

@@ -9,7 +9,7 @@ export default resolver.pipe(
resolver.zod(ChangePassword),
resolver.authorize(),
async ({ currentPassword, newPassword }, ctx) => {
const user = await db.user.findFirst({ where: { id: ctx.session.userId as number } })
const user = await db.user.findFirst({ where: { id: ctx.session.userId } })
if (!user) throw new NotFoundError()
await authenticateUser(user.email, currentPassword)

View File

@@ -2,6 +2,7 @@ import { setupBlitzServer } from "@blitzjs/next"
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
import db from "db"
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
import { BlitzLogger } from "blitz"
const { gSSP, gSP, api } = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const { gSSP, gSP, api } = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export { gSSP, gSP, api }

View File

@@ -5,7 +5,7 @@ export default async function getCurrentUser(_ = null, { session }: Ctx) {
if (!session.userId) return null
const user = await db.user.findFirst({
where: { id: session.userId as number },
where: { id: session.userId },
select: { id: true, name: true, email: true, role: true },
})

View File

@@ -29,7 +29,7 @@
"@blitzjs/rpc": "workspace:*",
"@hookform/resolvers": "2.8.8",
"@prisma/client": "4.0.0",
"blitz": "workspace:2.0.0-beta.4",
"blitz": "workspace:2.0.0-beta.15",
"next": "12.2.5",
"openid-client": "5.1.8",
"prisma": "4.0.0",
@@ -49,7 +49,7 @@
"@types/react": "18.0.17",
"@typescript-eslint/eslint-plugin": "5.9.1",
"eslint": "7.32.0",
"eslint-config-next": "12.2.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0",
"husky": "7.0.4",
"jest": "27.5.1",

View File

@@ -2,7 +2,7 @@ import { Suspense } from "react"
import Image from "next/image"
import Link from "next/link"
import Layout from "app/core/layouts/Layout"
import { useCurrentUser } from "app/core/hooks/useCurrentUser"
import { useCurrentUser } from "app/users/hooks/useCurrentUser"
import logout from "app/auth/mutations/logout"
import logo from "public/logo.png"
import { useMutation } from "@blitzjs/rpc"

View File

@@ -92,8 +92,6 @@ __name__
│ │ ├── components/
│ │ │ ├── Form.tsx
│ │ │ └── LabeledTextField.tsx
│ │ ├── hooks/
│ │ │ └── useCurrentUser.ts
│ │ └── layouts/
│ │ └── Layout.tsx
│ ├── pages/
@@ -103,6 +101,8 @@ __name__
│ │ ├── index.test.tsx
│ │ └── index.tsx
│ └── users/
│ ├── hooks/
│ │ └── useCurrentUser.ts
│ └── queries/
│ └── getCurrentUser.ts
├── db/

View File

@@ -9,7 +9,7 @@ export default resolver.pipe(
resolver.zod(ChangePassword),
resolver.authorize(),
async ({ currentPassword, newPassword }, ctx) => {
const user = await db.user.findFirst({ where: { id: ctx.session.userId as number } })
const user = await db.user.findFirst({ where: { id: ctx.session.userId } })
if (!user) throw new NotFoundError()
await authenticateUser(user.email, currentPassword)

View File

@@ -1,7 +1,9 @@
import type { BlitzCliConfig } from "blitz"
import { setupBlitzServer } from "@blitzjs/next"
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
import db from "db"
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
import { BlitzLogger } from "blitz"
const { gSSP, gSP, api } = setupBlitzServer({
plugins: [
@@ -11,6 +13,11 @@ const { gSSP, gSP, api } = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export { gSSP, gSP, api }
export const cliConfig: BlitzCliConfig = {
customTemplates: "app/templates",
}

View File

@@ -5,7 +5,7 @@ export default async function getCurrentUser(_ = null, { session }: Ctx) {
if (!session.userId) return null
const user = await db.user.findFirst({
where: { id: session.userId as number },
where: { id: session.userId },
select: { id: true, name: true, email: true, role: true },
})

View File

@@ -29,7 +29,7 @@
"@blitzjs/rpc": "workspace:*",
"@hookform/resolvers": "2.8.8",
"@prisma/client": "4.0.0",
"blitz": "workspace:2.0.0-beta.4",
"blitz": "workspace:2.0.0-beta.15",
"next": "12.2.5",
"prisma": "4.0.0",
"react": "18.2.0",
@@ -48,7 +48,7 @@
"@types/react": "18.0.17",
"@typescript-eslint/eslint-plugin": "5.9.1",
"eslint": "7.32.0",
"eslint-config-next": "12.2.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0",
"husky": "7.0.4",
"jest": "27.5.1",

View File

@@ -1,3 +1,4 @@
import { useEffect, useState } from "react"
import Layout from "app/core/layouts/Layout"
import { LabeledTextField } from "app/core/components/LabeledTextField"
import { Form, FORM_ERROR } from "app/core/components/Form"
@@ -9,9 +10,14 @@ import { useMutation } from "@blitzjs/rpc"
import Link from "next/link"
const ResetPasswordPage: BlitzPage = () => {
const [token, setToken] = useState("")
const router = useRouter()
const [resetPasswordMutation, { isSuccess }] = useMutation(resetPassword)
useEffect(() => {
setToken(router.query.token as string)
}, [router.isReady])
return (
<div>
<h1>Set a New Password</h1>
@@ -30,11 +36,11 @@ const ResetPasswordPage: BlitzPage = () => {
initialValues={{
password: "",
passwordConfirmation: "",
token: router.query.token as string,
token,
}}
onSubmit={async (values) => {
try {
await resetPasswordMutation(values)
await resetPasswordMutation({ ...values, token })
} catch (error: any) {
if (error.name === "ResetPasswordError") {
return {

View File

@@ -2,11 +2,12 @@ import { Suspense } from "react"
import Image from "next/image"
import Link from "next/link"
import Layout from "app/core/layouts/Layout"
import { useCurrentUser } from "app/core/hooks/useCurrentUser"
import { useCurrentUser } from "app/users/hooks/useCurrentUser"
import logout from "app/auth/mutations/logout"
import logo from "public/logo.png"
import { useMutation } from "@blitzjs/rpc"
import { Routes, BlitzPage } from "@blitzjs/next"
import { getSession, useSession } from "@blitzjs/auth"
/*
* This file is just for a pleasant getting started page for your new app.

View File

@@ -0,0 +1,27 @@
import { useCurrentUser } from "app/users/hooks/useCurrentUser"
import { render } from "test/utils"
import Home from "../pages/index"
jest.mock("app/users/hooks/useCurrentUser")
const mockUseCurrentUser = useCurrentUser as jest.MockedFunction<typeof useCurrentUser>
describe("renders blitz documentation link", () => {
it("test", () => {
// This is an example of how to ensure a specific item is in the document
// But it's disabled by default (by test.skip) so the test doesn't fail
// when you remove the the default content from the page
// This is an example on how to mock api hooks when testing
mockUseCurrentUser.mockReturnValue({
id: 1,
name: "User",
email: "user@email.com",
role: "user",
})
const { getByText } = render(<Home />)
const linkElement = getByText(/Documentation/i)
expect(linkElement).toBeInTheDocument()
})
})

View File

@@ -0,0 +1,104 @@
import { render as defaultRender } from "@testing-library/react"
import { renderHook as defaultRenderHook } from "@testing-library/react-hooks"
import { NextRouter } from "next/router"
import { BlitzProvider, RouterContext } from "@blitzjs/next"
import { QueryClient } from "@blitzjs/rpc"
export * from "@testing-library/react"
// --------------------------------------------------------------------------------
// This file customizes the render() and renderHook() test functions provided
// by React testing library. It adds a router context wrapper with a mocked router.
//
// You should always import `render` and `renderHook` from this file
//
// This is the place to add any other context providers you need while testing.
// --------------------------------------------------------------------------------
// --------------------------------------------------
// render()
// --------------------------------------------------
// Override the default test render with our own
//
// You can override the router mock like this:
//
// const { baseElement } = render(<MyComponent />, {
// router: { pathname: '/my-custom-pathname' },
// });
// --------------------------------------------------
const queryClient = new QueryClient()
export function render(
ui: RenderUI,
{ wrapper, router, dehydratedState, ...options }: RenderOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
wrapper = ({ children }: { children: React.ReactNode }) => (
<BlitzProvider dehydratedState={dehydratedState} client={queryClient}>
<RouterContext.Provider value={{ ...mockRouter, ...router }}>
{children}
</RouterContext.Provider>
</BlitzProvider>
)
}
return defaultRender(ui, { wrapper, ...options })
}
// --------------------------------------------------
// renderHook()
// --------------------------------------------------
// Override the default test renderHook with our own
//
// You can override the router mock like this:
//
// const result = renderHook(() => myHook(), {
// router: { pathname: '/my-custom-pathname' },
// });
// --------------------------------------------------
export function renderHook(
hook: RenderHook,
{ wrapper, router, dehydratedState, ...options }: RenderOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
wrapper = ({ children }: { children: React.ReactNode }) => (
<BlitzProvider dehydratedState={dehydratedState} client={queryClient}>
<RouterContext.Provider value={{ ...mockRouter, ...router }}>
{children}
</RouterContext.Provider>
</BlitzProvider>
)
}
return defaultRenderHook(hook, { wrapper, ...options })
}
export const mockRouter: NextRouter = {
basePath: "",
pathname: "/",
route: "/",
asPath: "/",
query: {},
isReady: true,
isLocaleDomain: false,
isPreview: false,
push: jest.fn(),
replace: jest.fn(),
reload: jest.fn(),
back: jest.fn(),
prefetch: jest.fn(),
beforePopState: jest.fn(),
events: {
on: jest.fn(),
off: jest.fn(),
emit: jest.fn(),
},
isFallback: false,
}
type DefaultParams = Parameters<typeof defaultRender>
type RenderUI = DefaultParams[0]
type RenderOptions = DefaultParams[1] & { router?: Partial<NextRouter>; dehydratedState?: unknown }
type DefaultHookParams = Parameters<typeof defaultRenderHook>
type RenderHook = DefaultHookParams[0]

View File

@@ -1,7 +1,8 @@
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import db from "db"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import {BlitzLogger} from "blitz"
import db from "db"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,10 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({
colorizePrettyLogs: true,
prefix: ["[blitz]>>>>>"],
}),
})
export {gSSP, gSP, api}

View File

@@ -1,7 +1,8 @@
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "../prisma/index"
import db from "../db/index"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -2,7 +2,6 @@ import {enhancePrisma} from "blitz"
import {PrismaClient} from "@prisma/client"
const EnhancedPrisma = enhancePrisma(PrismaClient)
export * from "@prisma/client"
const prisma = new EnhancedPrisma()
export default prisma

View File

@@ -1,20 +1,16 @@
import prisma from "./index"
import { SecurePassword } from "@blitzjs/auth"
import {SecurePassword} from "@blitzjs/auth"
const seed = async () => {
// await prisma.$reset()
const hashedPassword = await SecurePassword.hash("abcd1234")
await prisma.user.create({
data: {
email: "test@test.com",
hashedPassword,
role: "user",
},
}).catch(console.error)
process.exit(0);
})
process.exit(0)
}
seed()

View File

@@ -3,16 +3,17 @@
"version": "0.0.0",
"private": true,
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} db/seed.ts",
"schema": "db/schema.prisma"
},
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"test": "pnpm run prisma:start && vitest run",
"start:dev": "pnpm run prisma:start && blitz dev",
"test": "vitest run",
"test-watch": "vitest",
"start": "next start",
"start": "blitz start",
"lint": "next lint",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
"prisma:start": "prisma generate && prisma migrate dev",
"prisma:start": "blitz prisma migrate deploy",
"prisma:studio": "prisma studio"
},
"dependencies": {
@@ -20,7 +21,7 @@
"@blitzjs/config": "workspace:*",
"@blitzjs/next": "workspace:*",
"@prisma/client": "4.0.0",
"blitz": "workspace:*",
"blitz": "workspace:2.0.0-beta.15",
"lowdb": "3.0.0",
"next": "12.2.5",
"prisma": "4.0.0",

View File

@@ -1,5 +1,5 @@
import {api} from "../../app/blitz-server"
import prisma from "../../prisma/index"
import prisma from "../../db/index"
import {SecurePassword} from "@blitzjs/auth"
import {Role} from "../../types"

View File

@@ -1,11 +1,22 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {killApp, findPort, launchApp, nextBuild, nextStart} from "../../utils/next-test-utils"
import {
killApp,
findPort,
launchApp,
nextBuild,
nextStart,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import {join} from "path"
import seed from "../prisma/seed"
import fetch from "node-fetch"
import {fromBase64} from "b64-lite"
import seed from "../db/seed"
import prisma from "../db"
let app: any
let appPort: number
@@ -126,9 +137,9 @@ describe("Auth Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
// await seed()
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -140,9 +151,11 @@ describe("Auth Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

View File

@@ -1,5 +1,5 @@
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
import {User} from "./prisma"
import {User} from "./db"
export type Role = "ADMIN" | "USER"

View File

@@ -2,6 +2,7 @@ import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "../db"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -1,7 +0,0 @@
import prisma from "./index"
const seed = async () => {
await prisma.$reset()
}
export default seed

View File

@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"test": "pnpm run prisma:start && vitest run",
"test": "vitest run",
"test-watch": "vitest",
"start": "next start",
"lint": "next lint",

View File

@@ -1,5 +1,15 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {killApp, findPort, launchApp, nextBuild, nextStart} from "../../utils/next-test-utils"
import {
killApp,
findPort,
launchApp,
nextBuild,
nextStart,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import {join} from "path"
@@ -40,8 +50,9 @@ describe("getInitialProps Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -53,9 +64,11 @@ describe("getInitialProps Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

View File

@@ -0,0 +1,8 @@
import {defineConfig} from "vitest/config"
export default defineConfig({
test: {
testTimeout: 5000 * 60 * 2,
hookTimeout: 100000,
},
})

View File

@@ -1,7 +1,9 @@
import {setupBlitzServer} from "@blitzjs/next"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -6,6 +6,9 @@ import {
nextBuild,
nextStart,
fetchViaHTTP,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import {join} from "path"
@@ -46,7 +49,7 @@ describe("Middleware Tests", () => {
beforeAll(async () => {
try {
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -58,9 +61,9 @@ describe("Middleware Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

View File

@@ -3,6 +3,7 @@ import {defineConfig} from "vitest/config"
export default defineConfig({
test: {
testTimeout: 5000 * 60 * 2,
hookTimeout: 100000,
},
})

View File

@@ -1,7 +1,8 @@
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "../prisma/index"
import db from "../db/index"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -2,9 +2,12 @@
"name": "test-no-suspense",
"version": "0.0.0",
"private": true,
"prisma": {
"schema": "db/schema.prisma"
},
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"test": "pnpm run prisma:start && vitest run",
"test": "vitest run",
"test-watch": "vitest",
"start": "next start",
"lint": "next lint",

View File

@@ -1,7 +0,0 @@
import prisma from "./index"
const seed = async () => {
await prisma.$reset()
}
export default seed

View File

@@ -1,5 +1,15 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {killApp, findPort, launchApp, nextBuild, nextStart} from "../../utils/next-test-utils"
import {
killApp,
findPort,
launchApp,
nextBuild,
nextStart,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import {join} from "path"
@@ -30,8 +40,9 @@ describe("No Suspense Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -43,9 +54,11 @@ describe("No Suspense Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

View File

@@ -1,5 +1,5 @@
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
import {User} from "./prisma"
import {User} from "./db"
export type Role = "ADMIN" | "USER"

View File

@@ -1,12 +1,14 @@
/// <reference types="vitest" />
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import {defineConfig} from "vitest/config"
import react from "@vitejs/plugin-react"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
environment: "jsdom",
testTimeout: 5000 * 60 * 2,
hookTimeout: 100000,
},
})
})

View File

@@ -2,6 +2,7 @@ import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "../db"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -0,0 +1,6 @@
import {resolver} from "@blitzjs/rpc"
export default resolver.pipe(async (input, ctx) => {
await new Promise((r) => setTimeout(r, 4000))
return "thanks"
})

View File

@@ -0,0 +1,6 @@
const cache = {}
export default async function getSequence(key: string) {
cache[key] = cache[key] || 0
return cache[key]++
}

View File

@@ -1,7 +0,0 @@
import prisma from "./index"
const seed = async () => {
await prisma.$reset()
}
export default seed

View File

@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"test": "pnpm run prisma:start && vitest run",
"test": "vitest run",
"test-watch": "vitest",
"start": "next start",
"lint": "next lint",

View File

@@ -0,0 +1,55 @@
import React, {Suspense} from "react"
import {BlitzPage} from "@blitzjs/next"
import {invalidateQuery, useQuery} from "@blitzjs/rpc"
import getSequence from "../app/queries/getSequence"
const useQueryOptions = {
refetchInterval: 0,
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
}
const PageWithInvalidateQuery: React.FC = () => {
const [query1, {isFetching: isQ1Fetching}] = useQuery(getSequence, "query1", useQueryOptions)
const [query2, {isFetching: isQ2Fetching}] = useQuery(getSequence, "query2", useQueryOptions)
const isFetching = isQ1Fetching || isQ2Fetching
const onRevalidateBoth = async () => {
await invalidateQuery(getSequence)
}
const onRevalidateFirst = async () => {
await invalidateQuery(getSequence, "query1")
}
return (
<div>
<h1>Hello from PageWithInvalidateQuery</h1>
<button id="invalidate-both" onClick={onRevalidateBoth}>
Both
</button>
<button id="invalidate-first" onClick={onRevalidateFirst}>
First
</button>
{isFetching && <h3>Loading...</h3>}
{!isFetching && (
<div id="data">
<h2 id="data-first">{query1}</h2>
<h2 id="data-second">{query2}</h2>
</div>
)}
</div>
)
}
const PageWithInvalidateQueryPage: BlitzPage = () => {
return (
<Suspense fallback={<h1>Loading...</h1>}>
<PageWithInvalidateQuery />
</Suspense>
)
}
export default PageWithInvalidateQueryPage

View File

@@ -0,0 +1,26 @@
import {useInfiniteQuery} from "@blitzjs/rpc"
import {gSSP} from "../app/blitz-server"
import testQuery from "../app/queries/getInfiniteData"
export const getServerSideProps = gSSP(async ({ctx}) => {
const {prefetchInfiniteQuery} = ctx
await prefetchInfiniteQuery(testQuery, {
name: "hello world",
})
return {props: {}}
})
const PageWithPrefetchInfQuery = () => {
const [data] = useInfiniteQuery(
testQuery,
(pageParams) => ({...pageParams, name: "hello world"}),
{
suspense: false,
getNextPageParam: (lastPage) => lastPage,
},
)
return <div id="data">{data ? data : "no-data"}</div>
}
export default PageWithPrefetchInfQuery

View File

@@ -1,14 +1,18 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {killApp, findPort, launchApp, nextBuild, nextStart} from "../../utils/next-test-utils"
import {
killApp,
findPort,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import {join} from "path"
let app: any
let appPort: number
const appDir = join(__dirname, "../")
const runTests = (mode?: string) => {
const runTests = () => {
describe("get query data", () => {
it(
"should work",
@@ -27,13 +31,73 @@ const runTests = (mode?: string) => {
5000 * 60 * 2,
)
})
describe("prefetch infinite query", () => {
it(
"should work",
async () => {
const browser = await webdriver(appPort, "/page-with-prefetch-inf-query")
browser.waitForElementByCss("#data", 0)
const newText = await browser.elementByCss("#data").text()
expect(newText).not.toMatch("no-data")
expect(newText).toMatch("thanks")
if (browser) await browser.close()
},
5000 * 60 * 2,
)
})
describe("invalidate query", () => {
it(
"should work",
async () => {
const browser = await webdriver(appPort, "/page-with-invalidate")
const getData = async () => {
const q1 = await browser.elementByCss("#data-first").text()
const q2 = await browser.elementByCss("#data-second").text()
return {q1: parseInt(q1), q2: parseInt(q2)}
}
browser.waitForElementByCss("#data", 0)
const initialData = await getData()
expect(initialData.q1).equal(0)
expect(initialData.q2).equal(0)
browser.elementByCss("#invalidate-both").click() // sometimes first one returns the same value
await new Promise((r) => setTimeout(r, 100))
browser.elementByCss("#invalidate-both").click()
browser.waitForElementByCss("#data", 0)
const bothData = await getData()
expect(bothData.q1).greaterThan(initialData.q1)
expect(bothData.q2).greaterThan(initialData.q2)
browser.elementByCss("#invalidate-first").click()
browser.waitForElementByCss("#data", 0)
const afterSecond = await getData()
expect(afterSecond.q1).equal(bothData.q1 + 1)
expect(afterSecond.q2).equal(bothData.q2)
if (browser) await browser.close()
},
5000 * 60 * 2,
)
})
}
describe("React Query Utils Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -45,9 +109,11 @@ describe("React Query Utils Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

View File

@@ -2,6 +2,7 @@ import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
import db from "../db"
import {BlitzLogger} from "blitz"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
@@ -11,6 +12,7 @@ const {gSSP, gSP, api} = setupBlitzServer({
isAuthorized: simpleRolesIsAuthorized,
}),
],
logger: BlitzLogger({}),
})
export {gSSP, gSP, api}

View File

@@ -1,7 +0,0 @@
import prisma from "./index"
const seed = async () => {
await prisma.$reset()
}
export default seed

View File

@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"test": "pnpm run prisma:start && vitest run",
"test": "vitest run",
"test-watch": "vitest",
"start": "next start",
"lint": "next lint",

View File

@@ -1,5 +1,15 @@
import {describe, it, expect, beforeAll, afterAll} from "vitest"
import {killApp, findPort, launchApp, nextBuild, nextStart} from "../../utils/next-test-utils"
import {
killApp,
findPort,
launchApp,
nextBuild,
nextStart,
runBlitzCommand,
blitzLaunchApp,
blitzBuild,
blitzStart,
} from "../../utils/next-test-utils"
import webdriver from "../../utils/next-webdriver"
import {join} from "path"
@@ -29,8 +39,9 @@ describe("Trailing Slash Tests", () => {
describe("dev mode", () => {
beforeAll(async () => {
try {
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
appPort = await findPort()
app = await launchApp(appDir, appPort, {cwd: process.cwd()})
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
} catch (error) {
console.log(error)
}
@@ -42,9 +53,11 @@ describe("Trailing Slash Tests", () => {
describe("server mode", () => {
beforeAll(async () => {
try {
await nextBuild(appDir)
await runBlitzCommand(["prisma", "generate"])
await runBlitzCommand(["prisma", "migrate", "deploy"])
await blitzBuild()
appPort = await findPort()
app = await nextStart(appDir, appPort, {cwd: process.cwd()})
app = await blitzStart(appPort, {cwd: process.cwd()})
} catch (err) {
console.log(err)
}

Some files were not shown because too many files have changed in this diff Show More