Compare commits
30 Commits
@blitzjs/a
...
@blitzjs/c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58bb38f809 | ||
|
|
1476a577bb | ||
|
|
4e3c25d9a0 | ||
|
|
2ade7268e2 | ||
|
|
aa34661fac | ||
|
|
d98e4bac4e | ||
|
|
0473020555 | ||
|
|
8a88dec873 | ||
|
|
d6717b9d3c | ||
|
|
eb970f7bbc | ||
|
|
8e0c9d76b5 | ||
|
|
bd09db7533 | ||
|
|
83281a8469 | ||
|
|
15d22af24a | ||
|
|
1c3106eacf | ||
|
|
af58e2b239 | ||
|
|
430f6ec782 | ||
|
|
e2c18895da | ||
|
|
3b3c245fb1 | ||
|
|
7b00c17376 | ||
|
|
b43c1a81cc | ||
|
|
1742eb45db | ||
|
|
824a9b5e29 | ||
|
|
9db6c88555 | ||
|
|
25f4526f7e | ||
|
|
9fe0cc5468 | ||
|
|
0edeaa37a3 | ||
|
|
bf4aaf1de6 | ||
|
|
b3b4c21501 | ||
|
|
757789c43b |
@@ -3689,7 +3689,9 @@
|
||||
"profile": "https://github.com/siddhsuresh",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
"code",
|
||||
"test",
|
||||
"maintenance"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3716,4 +3718,4 @@
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
"skipCi": true
|
||||
}
|
||||
}
|
||||
|
||||
5
.changeset/blue-flowers-peel.md
Normal file
5
.changeset/blue-flowers-peel.md
Normal 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
|
||||
5
.changeset/breezy-bees-beg.md
Normal file
5
.changeset/breezy-bees-beg.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix `blitz --help` CLI command not being found
|
||||
@@ -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-*"]
|
||||
}
|
||||
|
||||
5
.changeset/eleven-lobsters-drop.md
Normal file
5
.changeset/eleven-lobsters-drop.md
Normal 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
|
||||
5
.changeset/empty-pants-search.md
Normal file
5
.changeset/empty-pants-search.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Load schema.prisma path from `package.json` instead of assuming it's `db/schema.prisma`
|
||||
5
.changeset/few-shrimps-leave.md
Normal file
5
.changeset/few-shrimps-leave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Add `blitz routes` CLI command back to toolkit
|
||||
11
.changeset/gentle-lions-explode.md
Normal file
11
.changeset/gentle-lions-explode.md
Normal 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
|
||||
5
.changeset/happy-bees-lick.md
Normal file
5
.changeset/happy-bees-lick.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Fix prefetching infinite Blitz queries.
|
||||
5
.changeset/happy-paws-join.md
Normal file
5
.changeset/happy-paws-join.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Move `useCurrentUser` hook from `core/hooks` to `users/hooks` folder
|
||||
7
.changeset/heavy-cobras-own.md
Normal file
7
.changeset/heavy-cobras-own.md
Normal 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.
|
||||
5
.changeset/hip-buttons-dance.md
Normal file
5
.changeset/hip-buttons-dance.md
Normal 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.
|
||||
5
.changeset/honest-cherries-push.md
Normal file
5
.changeset/honest-cherries-push.md
Normal 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.
|
||||
5
.changeset/itchy-houses-marry.md
Normal file
5
.changeset/itchy-houses-marry.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Add `blitz export` CLI command to toolkit
|
||||
6
.changeset/itchy-spoons-tan.md
Normal file
6
.changeset/itchy-spoons-tan.md
Normal 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
|
||||
5
.changeset/new-olives-protect.md
Normal file
5
.changeset/new-olives-protect.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Unwrap `invokeWithMiddleware` so the query or mutation is called directly when running the codemod
|
||||
5
.changeset/olive-kings-invent.md
Normal file
5
.changeset/olive-kings-invent.md
Normal 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.
|
||||
5
.changeset/orange-mirrors-tap.md
Normal file
5
.changeset/orange-mirrors-tap.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Fix eslint config in new JavaScript app templates
|
||||
@@ -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",
|
||||
@@ -49,7 +75,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 +86,7 @@
|
||||
"fast-clocks-push",
|
||||
"fast-trainers-kneel",
|
||||
"few-dogs-fetch",
|
||||
"few-shrimps-leave",
|
||||
"flat-bees-approve",
|
||||
"fluffy-mangos-begin",
|
||||
"fluffy-mice-wash",
|
||||
@@ -68,6 +97,7 @@
|
||||
"fuzzy-bees-warn",
|
||||
"fuzzy-jars-admire",
|
||||
"gentle-dogs-reply",
|
||||
"gentle-lions-explode",
|
||||
"gold-horses-punch",
|
||||
"good-apes-drum",
|
||||
"good-insects-wink",
|
||||
@@ -79,13 +109,20 @@
|
||||
"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",
|
||||
"hot-cups-rhyme",
|
||||
"hot-drinks-approve",
|
||||
"hungry-baboons-swim",
|
||||
"itchy-houses-marry",
|
||||
"itchy-spoons-tan",
|
||||
"kind-walls-suffer",
|
||||
"late-steaks-give",
|
||||
"lazy-maps-sort",
|
||||
@@ -108,6 +145,7 @@
|
||||
"nervous-beds-travel",
|
||||
"nervous-dolls-rule",
|
||||
"new-coats-turn",
|
||||
"new-olives-protect",
|
||||
"nice-deers-dream",
|
||||
"nice-starfishes-live",
|
||||
"nine-birds-confess",
|
||||
@@ -117,7 +155,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",
|
||||
@@ -163,14 +203,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 +222,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 +240,7 @@
|
||||
"violet-bags-leave",
|
||||
"violet-lions-help",
|
||||
"weak-suns-shave",
|
||||
"wicked-badgers-smoke",
|
||||
"wicked-ghosts-cough",
|
||||
"wicked-rings-walk",
|
||||
"wise-eels-visit",
|
||||
|
||||
5
.changeset/spotty-lies-visit.md
Normal file
5
.changeset/spotty-lies-visit.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/codemod": patch
|
||||
---
|
||||
|
||||
Fix detecting `blitz.config.(ts|js)` config file when running the codemod.
|
||||
5
.changeset/spotty-zoos-film.md
Normal file
5
.changeset/spotty-zoos-film.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Add `blitz console` CLI command back to toolkit
|
||||
5
.changeset/strong-keys-lie.md
Normal file
5
.changeset/strong-keys-lie.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Remove `views` property from `Session.PublicData` in `types.ts` file
|
||||
6
.changeset/tame-pumpkins-nail.md
Normal file
6
.changeset/tame-pumpkins-nail.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix invalidateQuery generating wrong param when no param argument is passed
|
||||
6
.changeset/thirty-spies-applaud.md
Normal file
6
.changeset/thirty-spies-applaud.md
Normal 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.
|
||||
7
.changeset/twelve-needles-worry.md
Normal file
7
.changeset/twelve-needles-worry.md
Normal 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
|
||||
5
.changeset/wicked-badgers-smoke.md
Normal file
5
.changeset/wicked-badgers-smoke.md
Normal 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.
|
||||
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
9
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -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
26
.github/workflows/changeset_check.yml
vendored
Normal 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: ${{ github.event.label.name != 'no-changeset' }}
|
||||
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}
|
||||
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -127,8 +127,8 @@ 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)')
|
||||
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 "::set-output name=folders::$folders"
|
||||
|
||||
Integration-Tests:
|
||||
@@ -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
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
13
README.md
13
README.md
@@ -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,7 +723,7 @@ 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>
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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.11",
|
||||
"next": "12.2.5",
|
||||
"openid-client": "5.1.8",
|
||||
"prisma": "4.0.0",
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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.11",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.0.0",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -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"
|
||||
@@ -271,4 +271,6 @@ const Home: BlitzPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
Home.authenticate = true
|
||||
|
||||
export default Home
|
||||
|
||||
27
apps/toolkit-app/test/index.test.tsx
Normal file
27
apps/toolkit-app/test/index.test.tsx
Normal 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()
|
||||
})
|
||||
})
|
||||
104
apps/toolkit-app/test/utils.tsx
Normal file
104
apps/toolkit-app/test/utils.tsx
Normal 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]
|
||||
@@ -1,7 +1,7 @@
|
||||
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"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
@@ -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.11",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.0.0",
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {User} from "./prisma"
|
||||
import {User} from "./db"
|
||||
|
||||
export type Role = "ADMIN" | "USER"
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
}
|
||||
|
||||
export default seed
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
8
integration-tests/get-initial-props/vitest.config.ts
Normal file
8
integration-tests/get-initial-props/vitest.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import {defineConfig} from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
testTimeout: 5000 * 60 * 2,
|
||||
hookTimeout: 100000,
|
||||
},
|
||||
})
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {defineConfig} from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
testTimeout: 5000 * 60 * 2,
|
||||
hookTimeout: 100000,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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"
|
||||
|
||||
const {gSSP, gSP, api} = setupBlitzServer({
|
||||
plugins: [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
}
|
||||
|
||||
export default seed
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {SimpleRolesIsAuthorized} from "@blitzjs/auth"
|
||||
import {User} from "./prisma"
|
||||
import {User} from "./db"
|
||||
|
||||
export type Role = "ADMIN" | "USER"
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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"
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
const cache = {}
|
||||
|
||||
export default async function getSequence(key: string) {
|
||||
cache[key] = cache[key] || 0
|
||||
return cache[key]++
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
}
|
||||
|
||||
export default seed
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import prisma from "./index"
|
||||
|
||||
const seed = async () => {
|
||||
await prisma.$reset()
|
||||
}
|
||||
|
||||
export default seed
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
8
integration-tests/trailing-slash/vitest.config.ts
Normal file
8
integration-tests/trailing-slash/vitest.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import {defineConfig} from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
testTimeout: 5000 * 60 * 2,
|
||||
hookTimeout: 100000,
|
||||
},
|
||||
})
|
||||
@@ -57,6 +57,7 @@ const BlitzProvider = ({
|
||||
|
||||
return children
|
||||
}
|
||||
|
||||
const compose =
|
||||
(...rest) =>
|
||||
(x: React.ComponentType<any>) =>
|
||||
|
||||
@@ -141,6 +141,180 @@ export function getCommandBin(
|
||||
return path.resolve(rootFolder, bin)
|
||||
}
|
||||
|
||||
export function runBlitzCommand(argv, options: RunNextCommandOptions = {}) {
|
||||
const nextnextbin = getCommandBin("blitz", options.cwd)
|
||||
const blitzBin = path.join(nextnextbin, "dist/index.cjs")
|
||||
const cwd = options.cwd || process.cwd()
|
||||
// Let Next.js decide the environment
|
||||
const env = {
|
||||
...process.env,
|
||||
NODE_ENV: "production" as const,
|
||||
__NEXT_TEST_MODE: "true",
|
||||
...options.env,
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(`Running command "blitz ${argv.join(" ")}"`)
|
||||
const instance = spawn("node", [blitzBin, ...argv], {
|
||||
cwd,
|
||||
env,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
})
|
||||
|
||||
if (typeof options.instance === "function") {
|
||||
options.instance(instance)
|
||||
}
|
||||
|
||||
let mergedStdio = ""
|
||||
|
||||
let stderrOutput = ""
|
||||
if (options.stderr) {
|
||||
instance.stderr?.on("data", function (chunk) {
|
||||
mergedStdio += chunk
|
||||
stderrOutput += chunk
|
||||
|
||||
if (options.stderr === "log") {
|
||||
console.log(chunk.toString())
|
||||
}
|
||||
})
|
||||
} else {
|
||||
instance.stderr?.on("data", function (chunk) {
|
||||
mergedStdio += chunk
|
||||
})
|
||||
}
|
||||
|
||||
let stdoutOutput = ""
|
||||
if (options.stdout) {
|
||||
instance.stdout?.on("data", function (chunk) {
|
||||
mergedStdio += chunk
|
||||
stdoutOutput += chunk
|
||||
|
||||
if (options.stdout === "log") {
|
||||
console.log(chunk.toString())
|
||||
}
|
||||
})
|
||||
} else {
|
||||
instance.stdout?.on("data", function (chunk) {
|
||||
mergedStdio += chunk
|
||||
})
|
||||
}
|
||||
|
||||
instance.on("close", (code, signal) => {
|
||||
if (!options.stderr && !options.stdout && !options.ignoreFail && code !== 0) {
|
||||
return reject(new Error(`command failed with code ${code}\n${mergedStdio}`))
|
||||
}
|
||||
|
||||
resolve({
|
||||
code,
|
||||
signal,
|
||||
stdout: stdoutOutput,
|
||||
stderr: stderrOutput,
|
||||
})
|
||||
})
|
||||
|
||||
instance.on("error", (err: any) => {
|
||||
err.stdout = stdoutOutput
|
||||
err.stderr = stderrOutput
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function runBlitzCommandDev(argv, stdOut, opts: RunNextCommandDevOptions = {}) {
|
||||
const nextnextbin = getCommandBin("blitz", opts.cwd)
|
||||
const blitzBin = path.join(nextnextbin, "dist/index.cjs")
|
||||
|
||||
const cwd = opts.cwd
|
||||
const env = {
|
||||
...process.env,
|
||||
NODE_ENV: undefined,
|
||||
__NEXT_TEST_MODE: "true",
|
||||
...opts.env,
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const instance = spawn("node", [blitzBin, ...argv], {
|
||||
cwd,
|
||||
env,
|
||||
} as {})
|
||||
let didResolve = false
|
||||
|
||||
function handleStdout(data) {
|
||||
const message = data.toString()
|
||||
const bootupMarkers = {
|
||||
dev: /compiled .*successfully/i,
|
||||
start: /started server/i,
|
||||
}
|
||||
if (
|
||||
(opts.bootupMarker && opts.bootupMarker.test(message)) ||
|
||||
bootupMarkers[opts.nextStart || stdOut ? "start" : "dev"].test(message)
|
||||
) {
|
||||
if (!didResolve) {
|
||||
didResolve = true
|
||||
resolve(stdOut ? message : instance)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof opts.onStdout === "function") {
|
||||
opts.onStdout(message)
|
||||
}
|
||||
|
||||
if (opts.stdout !== false) {
|
||||
process.stdout.write(message)
|
||||
}
|
||||
}
|
||||
|
||||
function handleStderr(data) {
|
||||
const message = data.toString()
|
||||
if (typeof opts.onStderr === "function") {
|
||||
opts.onStderr(message)
|
||||
}
|
||||
|
||||
if (opts.stderr !== false) {
|
||||
process.stderr.write(message)
|
||||
}
|
||||
}
|
||||
|
||||
instance.stdout?.on("data", handleStdout)
|
||||
instance.stderr?.on("data", handleStderr)
|
||||
|
||||
instance.on("close", () => {
|
||||
instance.stdout?.removeListener("data", handleStdout)
|
||||
instance.stderr?.removeListener("data", handleStderr)
|
||||
if (!didResolve) {
|
||||
didResolve = true
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
|
||||
instance.on("error", (err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Blitz Utils
|
||||
export function blitzLaunchApp(port, opts: RunNextCommandDevOptions) {
|
||||
return runBlitzCommandDev(["dev", "-p", port], undefined, opts)
|
||||
}
|
||||
|
||||
export function blitzBuild(args = [], opts = {}): any {
|
||||
return runBlitzCommand(["build", ...args], opts)
|
||||
}
|
||||
|
||||
export function nextLint(args = [], opts = {}) {
|
||||
return runBlitzCommand(["lint", ...args], opts)
|
||||
}
|
||||
|
||||
export function blitzStart(port, opts = {}) {
|
||||
return runBlitzCommandDev(["start", "-p", port], undefined, {
|
||||
...opts,
|
||||
nextStart: true,
|
||||
})
|
||||
}
|
||||
|
||||
//Next Utils
|
||||
|
||||
export function runNextCommand(argv, options: RunNextCommandOptions = {}) {
|
||||
const nextnextbin = getCommandBin("next", options.cwd)
|
||||
const nextBin = path.join(nextnextbin, "dist/bin/next")
|
||||
@@ -295,7 +469,6 @@ export function runNextCommandDev(argv, stdOut, opts: RunNextCommandDevOptions =
|
||||
})
|
||||
}
|
||||
|
||||
// Launch the app in dev mode.
|
||||
export function launchApp(dir, port, opts: RunNextCommandDevOptions) {
|
||||
return runNextCommandDev([dir, "-p", port], undefined, opts)
|
||||
}
|
||||
@@ -312,10 +485,6 @@ export function nextExportDefault(dir, opts = {}) {
|
||||
return runNextCommand(["export", dir], opts)
|
||||
}
|
||||
|
||||
export function nextLint(dir, args = [], opts = {}) {
|
||||
return runNextCommand(["lint", dir, ...args], opts)
|
||||
}
|
||||
|
||||
export function nextStart(dir, port, opts = {}) {
|
||||
return runNextCommandDev(["start", "-p", port, dir], undefined, {
|
||||
...opts,
|
||||
@@ -683,20 +852,20 @@ function runSuite(suiteName, context, options) {
|
||||
}
|
||||
if (env === "prod") {
|
||||
context.appPort = await findPort()
|
||||
const {stdout, stderr, code} = await nextBuild(appDir, [], {
|
||||
const {stdout, stderr, code} = await blitzBuild([], {
|
||||
stderr: true,
|
||||
stdout: true,
|
||||
})
|
||||
context.stdout = stdout
|
||||
context.stderr = stderr
|
||||
context.code = code
|
||||
context.server = await nextStart(context.appDir, context.appPort, {
|
||||
context.server = await blitzStart(context.appPort, {
|
||||
onStderr,
|
||||
onStdout,
|
||||
})
|
||||
} else if (env === "dev") {
|
||||
context.appPort = await findPort()
|
||||
context.server = await launchApp(context.appDir, context.appPort, {
|
||||
context.server = await blitzLaunchApp(context.appPort, {
|
||||
onStderr,
|
||||
onStdout,
|
||||
})
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"workspaces": [
|
||||
"apps/*",
|
||||
"packages/*",
|
||||
"integration-tests/*"
|
||||
"integration-tests/*",
|
||||
"recipes/*"
|
||||
],
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
@@ -38,7 +39,7 @@
|
||||
"wait-on": "6.0.1"
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"packageManager": "pnpm@7.4.0-1",
|
||||
"packageManager": "pnpm@7.11.0",
|
||||
"manypkg": {
|
||||
"ignoredRules": [
|
||||
"EXTERNAL_MISMATCH"
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
# @blitzjs/auth
|
||||
|
||||
## 2.0.0-beta.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1476a577: Fix release
|
||||
- Updated dependencies [1476a577]
|
||||
- blitz@2.0.0-beta.11
|
||||
|
||||
## 2.0.0-beta.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9fe0cc54: Fix auth related React hydration errors by not redirecting until after component mount.
|
||||
- Updated dependencies [9db6c885]
|
||||
- Updated dependencies [d98e4bac]
|
||||
- Updated dependencies [9fe0cc54]
|
||||
- Updated dependencies [af58e2b2]
|
||||
- Updated dependencies [2ade7268]
|
||||
- Updated dependencies [0edeaa37]
|
||||
- Updated dependencies [430f6ec7]
|
||||
- Updated dependencies [15d22af2]
|
||||
- Updated dependencies [aa34661f]
|
||||
- Updated dependencies [8e0c9d76]
|
||||
- Updated dependencies [e2c18895]
|
||||
- blitz@2.0.0-beta.5
|
||||
|
||||
## 2.0.0-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/auth",
|
||||
"version": "2.0.0-beta.4",
|
||||
"version": "2.0.0-beta.11",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts",
|
||||
@@ -26,7 +26,7 @@
|
||||
"@types/secure-password": "3.1.1",
|
||||
"b64-lite": "1.4.0",
|
||||
"bad-behavior": "1.0.1",
|
||||
"blitz": "2.0.0-beta.4",
|
||||
"blitz": "2.0.0-beta.11",
|
||||
"cookie": "0.4.1",
|
||||
"cookie-session": "2.0.0",
|
||||
"debug": "4.3.3",
|
||||
@@ -40,7 +40,7 @@
|
||||
"url": "0.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.4",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.11",
|
||||
"@testing-library/react": "13.0.0",
|
||||
"@testing-library/react-hooks": "7.0.2",
|
||||
"@types/cookie": "0.4.1",
|
||||
|
||||
@@ -165,7 +165,13 @@ export const useSession = (options: UseSessionOptions = {}): ClientSession => {
|
||||
}
|
||||
|
||||
export const useAuthorizeIf = (condition?: boolean) => {
|
||||
if (isClient && condition && !getPublicDataStore().getData().userId) {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if (isClient && condition && !getPublicDataStore().getData().userId && mounted) {
|
||||
const error = new AuthenticationError()
|
||||
error.stack = null!
|
||||
throw error
|
||||
@@ -184,7 +190,13 @@ export const useAuthenticatedSession = (
|
||||
}
|
||||
|
||||
export const useRedirectAuthenticated = (to: UrlObject | string) => {
|
||||
if (isClient && getPublicDataStore().getData().userId) {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
if (isClient && getPublicDataStore().getData().userId && mounted) {
|
||||
const error = new RedirectError(to)
|
||||
error.stack = null!
|
||||
throw error
|
||||
@@ -248,6 +260,11 @@ export function getAuthValues<TProps = any>(
|
||||
function withBlitzAuthPlugin<TProps = any>(Page: ComponentType<TProps> | BlitzPage<TProps>) {
|
||||
const AuthRoot = (props: ComponentProps<any>) => {
|
||||
useSession({suspense: false})
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
}, [])
|
||||
|
||||
let {authenticate, redirectAuthenticatedTo} = getAuthValues(Page, props)
|
||||
|
||||
@@ -273,10 +290,12 @@ function withBlitzAuthPlugin<TProps = any>(Page: ComponentType<TProps> | BlitzPa
|
||||
? redirectAuthenticatedTo
|
||||
: formatWithValidation(redirectAuthenticatedTo)
|
||||
|
||||
debug("[BlitzAuthInnerRoot] redirecting to", redirectUrl)
|
||||
const error = new RedirectError(redirectUrl)
|
||||
error.stack = null!
|
||||
throw error
|
||||
if (mounted) {
|
||||
debug("[BlitzAuthInnerRoot] redirecting to", redirectUrl)
|
||||
const error = new RedirectError(redirectUrl)
|
||||
error.stack = null!
|
||||
throw error
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug("[BlitzAuthInnerRoot] logged out")
|
||||
@@ -288,10 +307,13 @@ function withBlitzAuthPlugin<TProps = any>(Page: ComponentType<TProps> | BlitzPa
|
||||
|
||||
const url = new URL(redirectTo, window.location.href)
|
||||
url.searchParams.append("next", window.location.pathname)
|
||||
debug("[BlitzAuthInnerRoot] redirecting to", url.toString())
|
||||
const error = new RedirectError(url.toString())
|
||||
error.stack = null!
|
||||
throw error
|
||||
|
||||
if (mounted) {
|
||||
debug("[BlitzAuthInnerRoot] redirecting to", url.toString())
|
||||
const error = new RedirectError(url.toString())
|
||||
error.stack = null!
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# @blitzjs/next
|
||||
|
||||
## 2.0.0-beta.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1476a577: Fix release
|
||||
- Updated dependencies [1476a577]
|
||||
- @blitzjs/rpc@2.0.0-beta.11
|
||||
|
||||
## 2.0.0-beta.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1742eb45: Fix prefetching infinite Blitz queries.
|
||||
- 9fe0cc54: Fix auth related React hydration errors by not redirecting until after component mount.
|
||||
- e2c18895: Add client testing utilities and a sample test to a new blitz app template
|
||||
- 25f4526f: Treat API Route handler as a middleware. This allows outer middlewares to completely wrap queries and mutations.
|
||||
- Updated dependencies [0edeaa37]
|
||||
- Updated dependencies [aa34661f]
|
||||
- Updated dependencies [8e0c9d76]
|
||||
- @blitzjs/rpc@2.0.0-beta.10
|
||||
|
||||
## 2.0.0-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/next",
|
||||
"version": "2.0.0-beta.4",
|
||||
"version": "2.0.0-beta.11",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "pnpm predev && pnpm watch unbuild src --wait=0.2",
|
||||
@@ -24,7 +24,7 @@
|
||||
"eslint.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@blitzjs/rpc": "2.0.0-beta.4",
|
||||
"@blitzjs/rpc": "2.0.0-beta.11",
|
||||
"@tanstack/react-query": "4.0.10",
|
||||
"@types/hoist-non-react-statics": "3.3.1",
|
||||
"debug": "4.3.3",
|
||||
@@ -34,7 +34,7 @@
|
||||
"supports-color": "8.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.4",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.11",
|
||||
"@testing-library/dom": "8.13.0",
|
||||
"@testing-library/jest-dom": "5.16.3",
|
||||
"@testing-library/react": "13.0.0",
|
||||
@@ -44,7 +44,7 @@
|
||||
"@types/react": "18.0.17",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"@types/testing-library__react-hooks": "4.0.0",
|
||||
"blitz": "2.0.0-beta.4",
|
||||
"blitz": "2.0.0-beta.11",
|
||||
"cross-spawn": "7.0.3",
|
||||
"find-up": "4.1.0",
|
||||
"next": "12.2.5",
|
||||
|
||||
@@ -81,6 +81,7 @@ class ErrorBoundary extends React.Component<
|
||||
|
||||
state = initialState
|
||||
updatedWithError = false
|
||||
|
||||
resetErrorBoundary = (...args: Array<unknown>) => {
|
||||
this.props.onReset?.(...args)
|
||||
this.reset()
|
||||
@@ -94,6 +95,7 @@ class ErrorBoundary extends React.Component<
|
||||
async componentDidCatch(error: Error, info: React.ErrorInfo) {
|
||||
if (error instanceof RedirectError) {
|
||||
debug("Redirecting from ErrorBoundary to", error.url)
|
||||
|
||||
await (this.context as Router)?.push(error.url)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import "./global"
|
||||
import type {
|
||||
ClientPlugin,
|
||||
BlitzProvider as BlitzProviderType,
|
||||
UnionToIntersection,
|
||||
Simplify,
|
||||
} from "blitz"
|
||||
import type {ClientPlugin, BlitzProviderComponentType, UnionToIntersection, Simplify} from "blitz"
|
||||
import Head from "next/head"
|
||||
import React, {ReactNode} from "react"
|
||||
import {QueryClient, QueryClientProvider, Hydrate, HydrateOptions} from "@tanstack/react-query"
|
||||
@@ -22,14 +17,14 @@ export * from "./router-context"
|
||||
export {Routes} from ".blitz"
|
||||
|
||||
const compose =
|
||||
(...rest: BlitzProviderType[]) =>
|
||||
(...rest: BlitzProviderComponentType[]) =>
|
||||
(x: React.ComponentType<any>) =>
|
||||
rest.reduceRight((y, f) => f(y), x)
|
||||
|
||||
const buildWithBlitz = <TPlugins extends readonly ClientPlugin<object>[]>(plugins: TPlugins) => {
|
||||
const providers = plugins.reduce((acc, plugin) => {
|
||||
return plugin.withProvider ? acc.concat(plugin.withProvider) : acc
|
||||
}, [] as BlitzProviderType[])
|
||||
}, [] as BlitzProviderComponentType[])
|
||||
|
||||
const withPlugins = compose(...providers)
|
||||
|
||||
|
||||
@@ -116,8 +116,13 @@ const prefetchQueryFactory = (
|
||||
queryClient = new QueryClient({defaultOptions})
|
||||
}
|
||||
|
||||
const queryKey = infinite ? getInfiniteQueryKey(fn, input) : getQueryKey(fn, input)
|
||||
await queryClient.prefetchQuery(queryKey, () => fn(input, ctx))
|
||||
if (infinite) {
|
||||
await queryClient.prefetchInfiniteQuery(getInfiniteQueryKey(fn, input), () =>
|
||||
fn(input, ctx),
|
||||
)
|
||||
} else {
|
||||
await queryClient.prefetchQuery(getQueryKey(fn, input), () => fn(input, ctx))
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -140,7 +145,8 @@ export const setupBlitzServer = ({plugins, onError}: SetupBlitzOptions) => {
|
||||
const {getClient, prefetchQuery} = prefetchQueryFactory(ctx)
|
||||
|
||||
ctx.prefetchQuery = prefetchQuery
|
||||
ctx.prefetchInfiniteQuery = (...args) => prefetchQuery(...args, true)
|
||||
ctx.prefetchInfiniteQuery = (fn, input, defaultOptions = {}) =>
|
||||
prefetchQuery(fn, input, defaultOptions, true)
|
||||
|
||||
try {
|
||||
const result = await handler({req, res, ctx, ...rest})
|
||||
@@ -187,8 +193,10 @@ export const setupBlitzServer = ({plugins, onError}: SetupBlitzOptions) => {
|
||||
): NextApiHandler<TResult | void> =>
|
||||
async (req, res) => {
|
||||
try {
|
||||
await handleRequestWithMiddleware(req, res, middlewares)
|
||||
return handler(req, res, res.blitzCtx)
|
||||
return await handleRequestWithMiddleware(req, res, [
|
||||
...middlewares,
|
||||
(req, res) => handler(req, res, res.blitzCtx),
|
||||
])
|
||||
} catch (error: any) {
|
||||
onError?.(error)
|
||||
return res.status(400).send(error)
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# @blitzjs/rpc
|
||||
|
||||
## 2.0.0-beta.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1476a577: Fix release
|
||||
- Updated dependencies [1476a577]
|
||||
- @blitzjs/auth@2.0.0-beta.11
|
||||
|
||||
## 2.0.0-beta.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0edeaa37: 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
|
||||
- aa34661f: Fix invalidateQuery generating wrong param when no param argument is passed
|
||||
- 8e0c9d76: Migrate over recipe functionality from legacy framework & expose recipe builder helper functions that find and modify next.config.js, blitz-server & blitz-client.
|
||||
- Updated dependencies [9fe0cc54]
|
||||
- @blitzjs/auth@2.0.0-beta.10
|
||||
|
||||
## 2.0.0-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@blitzjs/rpc",
|
||||
"version": "2.0.0-beta.4",
|
||||
"version": "2.0.0-beta.11",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts && wait-on -d 250 ../blitz-auth/dist/index-browser.d.ts",
|
||||
"predev": "wait-on -d 400 ../blitz/dist/index-server.d.ts && wait-on -d 400 ../blitz-auth/dist/index-browser.d.ts",
|
||||
"dev": "pnpm run predev && watch unbuild src --wait=0.2",
|
||||
"lint": "eslint . --fix",
|
||||
"test": "vitest run",
|
||||
@@ -20,7 +20,7 @@
|
||||
"dist/**"
|
||||
],
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "2.0.0-beta.4",
|
||||
"@blitzjs/auth": "2.0.0-beta.11",
|
||||
"@tanstack/react-query": "4.0.10",
|
||||
"b64-lite": "1.4.0",
|
||||
"bad-behavior": "1.0.1",
|
||||
@@ -30,11 +30,11 @@
|
||||
"supports-color": "8.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.4",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.11",
|
||||
"@types/debug": "4.1.7",
|
||||
"@types/react": "18.0.17",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"blitz": "2.0.0-beta.4",
|
||||
"blitz": "2.0.0-beta.11",
|
||||
"next": "12.2.5",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
|
||||
77
packages/blitz-rpc/src/data-client/react-query-utils.test.ts
Normal file
77
packages/blitz-rpc/src/data-client/react-query-utils.test.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import {describe, expect, it} from "vitest"
|
||||
import superJson from "superjson"
|
||||
|
||||
import {getQueryKey, getQueryKeyFromUrlAndParams} from "./react-query-utils"
|
||||
import {RpcClient} from "./rpc"
|
||||
|
||||
const API_ENDPOINT = "http://localhost:3000"
|
||||
|
||||
const constructData = (arg: any) => {
|
||||
return {
|
||||
data: arg,
|
||||
expected: superJson.serialize(arg),
|
||||
}
|
||||
}
|
||||
|
||||
describe("react-query-utils", () => {
|
||||
describe("getQueryKeyFromUrlAndParams", () => {
|
||||
it("returns a query key with string arg", () => {
|
||||
const {data, expected} = constructData("RandomString")
|
||||
expect(getQueryKeyFromUrlAndParams(API_ENDPOINT, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with object arg", () => {
|
||||
const {data, expected} = constructData({id: 1, name: "test", field: undefined})
|
||||
expect(getQueryKeyFromUrlAndParams(API_ENDPOINT, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with undefined arg", () => {
|
||||
const {data, expected} = constructData(undefined)
|
||||
expect(getQueryKeyFromUrlAndParams(API_ENDPOINT, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with null arg", () => {
|
||||
const {data, expected} = constructData(null)
|
||||
expect(getQueryKeyFromUrlAndParams(API_ENDPOINT, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("if no argument is passed it returns only url", () => {
|
||||
const queryKey = getQueryKeyFromUrlAndParams(API_ENDPOINT)
|
||||
expect(queryKey).toEqual([API_ENDPOINT])
|
||||
})
|
||||
})
|
||||
|
||||
describe("getQueryKey", () => {
|
||||
// @ts-expect-error - we just need these 3 params
|
||||
const query: RpcClient<{}, null> = {
|
||||
_resolverName: "randomQuery",
|
||||
_resolverType: "query",
|
||||
_routePath: API_ENDPOINT,
|
||||
}
|
||||
|
||||
it("returns a query key with string arg", () => {
|
||||
const {data, expected} = constructData("RandomString")
|
||||
expect(getQueryKey(query, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with object arg", () => {
|
||||
const {data, expected} = constructData({id: 1, name: "test", field: undefined})
|
||||
expect(getQueryKey(query, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with undefined arg", () => {
|
||||
const {data, expected} = constructData(undefined)
|
||||
expect(getQueryKey(query, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("returns a query key with null arg", () => {
|
||||
const {data, expected} = constructData(null)
|
||||
expect(getQueryKey(query, data)).toEqual([API_ENDPOINT, expected])
|
||||
})
|
||||
|
||||
it("if no argument is passed it returns only url", () => {
|
||||
const queryKey = getQueryKey(query)
|
||||
expect(queryKey).toEqual([API_ENDPOINT])
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import {QueryClient, QueryFilters} from "@tanstack/react-query"
|
||||
import {QueryClient} from "@tanstack/react-query"
|
||||
import {serialize} from "superjson"
|
||||
import {isClient, isServer, AsyncFunc} from "blitz"
|
||||
import {ResolverType, RpcClient} from "./rpc"
|
||||
@@ -124,24 +124,29 @@ const sanitize =
|
||||
export const sanitizeQuery = sanitize("query")
|
||||
export const sanitizeMutation = sanitize("mutation")
|
||||
|
||||
export const getQueryKeyFromUrlAndParams = (url: string, params: unknown) => {
|
||||
const queryKey = [url]
|
||||
type BlitzQueryKey = [string] | [string, any]
|
||||
export const getQueryKeyFromUrlAndParams = (
|
||||
url: string,
|
||||
...params: [unknown] | []
|
||||
): BlitzQueryKey => {
|
||||
const queryKey: BlitzQueryKey = [url]
|
||||
if (params.length === 1) {
|
||||
const param = params[0]
|
||||
queryKey.push(serialize(typeof param === "function" ? param() : param) as any)
|
||||
}
|
||||
|
||||
const args = typeof params === "function" ? (params as Function)() : params
|
||||
queryKey.push(serialize(args) as any)
|
||||
|
||||
return queryKey as [string, any]
|
||||
return queryKey
|
||||
}
|
||||
|
||||
export function getQueryKey<TInput, TResult, T extends AsyncFunc>(
|
||||
resolver: T | Resolver<TInput, TResult> | RpcClient<TInput, TResult>,
|
||||
params?: TInput,
|
||||
...params: [TInput] | []
|
||||
) {
|
||||
if (typeof resolver === "undefined") {
|
||||
throw new Error("getQueryKey is missing the first argument - it must be a resolver function")
|
||||
}
|
||||
|
||||
return getQueryKeyFromUrlAndParams(sanitizeQuery(resolver)._routePath, params)
|
||||
return getQueryKeyFromUrlAndParams(sanitizeQuery(resolver)._routePath, ...params)
|
||||
}
|
||||
|
||||
export function getInfiniteQueryKey<TInput, TResult, T extends AsyncFunc>(
|
||||
@@ -158,17 +163,23 @@ export function getInfiniteQueryKey<TInput, TResult, T extends AsyncFunc>(
|
||||
return [...queryKey, "infinite"]
|
||||
}
|
||||
|
||||
export function invalidateQuery<TInput, TResult, T extends AsyncFunc>(
|
||||
type InvalidateQueryTypeWithParams = <TInput, TResult, T extends AsyncFunc>(
|
||||
resolver: T | Resolver<TInput, TResult> | RpcClient<TInput, TResult>,
|
||||
params?: TInput,
|
||||
) {
|
||||
...params: [TInput]
|
||||
) => Promise<void>
|
||||
type InvalidateQueryTypeAllQueries = <TInput, TResult, T extends AsyncFunc>(
|
||||
resolver: T | Resolver<TInput, TResult> | RpcClient<TInput, TResult>,
|
||||
) => Promise<void>
|
||||
type InvalidateQueryType = InvalidateQueryTypeWithParams & InvalidateQueryTypeAllQueries
|
||||
|
||||
export const invalidateQuery: InvalidateQueryType = (resolver, ...params: []) => {
|
||||
if (typeof resolver === "undefined") {
|
||||
throw new Error(
|
||||
"invalidateQuery is missing the first argument - it must be a resolver function",
|
||||
)
|
||||
}
|
||||
|
||||
const fullQueryKey = getQueryKey(resolver, params)
|
||||
const fullQueryKey = getQueryKey(resolver, ...params)
|
||||
return getQueryClient().invalidateQueries(fullQueryKey)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ export function installWebpackConfig({
|
||||
webpackConfig.resolve.alias["npm-which"] = false
|
||||
webpackConfig.resolve.alias["cross-spawn"] = false
|
||||
webpackConfig.module.rules.push({
|
||||
test: /[\\/]\[\[\.\.\.blitz]]\.[jt]sx?$/,
|
||||
test: /[\\/]\[\[\.\.\.blitz]]?.+\.[jt]sx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: loaderServer,
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
# blitz
|
||||
|
||||
## 2.0.0-beta.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1476a577: Fix release
|
||||
- Updated dependencies [1476a577]
|
||||
- @blitzjs/generator@2.0.0-beta.11
|
||||
|
||||
## 2.0.0-beta.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9db6c885: Fix `blitz --help` CLI command not being found
|
||||
- d98e4bac: Add `blitz routes` CLI command back to toolkit
|
||||
- 9fe0cc54: Fix auth related React hydration errors by not redirecting until after component mount.
|
||||
- af58e2b2: Add a global Blitz version check when generating a new Blitz project to ensure users use the latest Blitz.
|
||||
- 2ade7268: Add `blitz export` CLI command to toolkit
|
||||
- 0edeaa37: 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
|
||||
- 430f6ec7: Only generate the prisma client if it's not found in node_modules when running a blitz cli command.
|
||||
- 15d22af2: Add `blitz console` CLI command back to toolkit
|
||||
- aa34661f: Fix invalidateQuery generating wrong param when no param argument is passed
|
||||
- 8e0c9d76: Migrate over recipe functionality from legacy framework & expose recipe builder helper functions that find and modify next.config.js, blitz-server & blitz-client.
|
||||
- e2c18895: Add client testing utilities and a sample test to a new blitz app template
|
||||
- Updated dependencies [04730205]
|
||||
- Updated dependencies [824a9b5e]
|
||||
- Updated dependencies [d6717b9d]
|
||||
- Updated dependencies [bf4aaf1d]
|
||||
- Updated dependencies [b43c1a81]
|
||||
- Updated dependencies [83281a84]
|
||||
- Updated dependencies [bd09db75]
|
||||
- Updated dependencies [e2c18895]
|
||||
- @blitzjs/generator@2.0.0-beta.10
|
||||
|
||||
## 2.0.0-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {BuildConfig} from "unbuild"
|
||||
|
||||
const config: BuildConfig = {
|
||||
entries: ["./src/index-browser", "./src/index-server", "./src/cli/index"],
|
||||
entries: ["./src/index-browser", "./src/index-server", "./src/cli/index", "./src/installer"],
|
||||
externals: ["index-browser.cjs", "index-browser.mjs", "index.cjs", "zod", "react"],
|
||||
declaration: true,
|
||||
rollup: {
|
||||
|
||||
1
packages/blitz/installer.d.ts
vendored
Normal file
1
packages/blitz/installer.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/installer"
|
||||
1
packages/blitz/installer.js
Normal file
1
packages/blitz/installer.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./dist/installer.cjs")
|
||||
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "blitz",
|
||||
"version": "2.0.0-beta.4",
|
||||
"version": "2.0.0-beta.11",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "watch unbuild src --wait=0.2",
|
||||
"dev": "pnpm run predev && watch unbuild src --wait=0.2",
|
||||
"lint": "eslint . --fix",
|
||||
"test": "vitest run",
|
||||
"test-watch": "vitest",
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
||||
"predev": "wait-on -d 250 ../generator/dist/index.d.ts"
|
||||
},
|
||||
"main": "./dist/index-server.cjs",
|
||||
"module": "./dist/index-server.mjs",
|
||||
@@ -23,39 +24,54 @@
|
||||
"blitz": "bin/blitz"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/generator": "2.0.0-beta.4",
|
||||
"@blitzjs/generator": "2.0.0-beta.11",
|
||||
"@mrleebo/prisma-ast": "0.2.6",
|
||||
"@types/global-agent": "2.1.1",
|
||||
"arg": "5.0.1",
|
||||
"ast-types": "0.14.2",
|
||||
"boxen": "7.0.0",
|
||||
"chalk": "^4.1.0",
|
||||
"chokidar": "3.5.3",
|
||||
"console-table-printer": "2.10.0",
|
||||
"cross-spawn": "7.0.3",
|
||||
"debug": "4.3.3",
|
||||
"detect-port": "1.3.0",
|
||||
"diff": "5.0.0",
|
||||
"dotenv": "16.0.0",
|
||||
"dotenv-expand": "8.0.3",
|
||||
"envinfo": "7.8.1",
|
||||
"esbuild": "0.14.34",
|
||||
"esbuild-register": "3.3.3",
|
||||
"find-up": "4.1.0",
|
||||
"fs-extra": "10.0.1",
|
||||
"global-agent": "3.0.0",
|
||||
"globby": "13.1.2",
|
||||
"got": "^11.8.1",
|
||||
"hasbin": "1.2.3",
|
||||
"ink": "3.2.0",
|
||||
"ink-spinner": "4.0.3",
|
||||
"jscodeshift": "0.13.0",
|
||||
"node-fetch": "3.2.3",
|
||||
"npm-which": "3.0.1",
|
||||
"ora": "5.3.0",
|
||||
"os-name": "5.0.1",
|
||||
"p-event": "4.2.0",
|
||||
"pkg-dir": "5.0.0",
|
||||
"progress": "2.0.3",
|
||||
"prompts": "2.4.2",
|
||||
"recast": "0.20.5",
|
||||
"resolve-cwd": "3.0.0",
|
||||
"resolve-from": "5.0.0",
|
||||
"superjson": "1.9.1",
|
||||
"supports-color": "8.1.1",
|
||||
"tar": "6.1.11",
|
||||
"ts-node": "10.7.0",
|
||||
"tsconfig-paths": "4.0.0",
|
||||
"tslog": "3.3.1",
|
||||
"watchpack": "2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.4",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.11",
|
||||
"@types/cookie": "0.4.1",
|
||||
"@types/cross-spawn": "6.0.2",
|
||||
"@types/debug": "4.1.7",
|
||||
@@ -64,8 +80,10 @@
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/hasbin": "1.2.0",
|
||||
"@types/jscodeshift": "0.11.2",
|
||||
"@types/node-fetch": "2.6.1",
|
||||
"@types/npm-which": "3.0.1",
|
||||
"@types/progress": "2.0.5",
|
||||
"@types/prompts": "2.0.14",
|
||||
"@types/react": "18.0.17",
|
||||
"@types/react-dom": "17.0.14",
|
||||
|
||||
47
packages/blitz/src/cli/commands/console.ts
Normal file
47
packages/blitz/src/cli/commands/console.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {CliCommand} from "../index"
|
||||
import arg from "arg"
|
||||
import chalk from "chalk"
|
||||
import {log} from "../../logging"
|
||||
import {runRepl, getDbFolder} from "../utils/next-console"
|
||||
|
||||
const args = arg(
|
||||
{
|
||||
// Types
|
||||
"--only-db": Boolean,
|
||||
|
||||
// Aliases
|
||||
"-d": "--only-db",
|
||||
},
|
||||
{
|
||||
permissive: true,
|
||||
},
|
||||
)
|
||||
|
||||
const replOptions = {
|
||||
prompt: "⚡️ > ",
|
||||
useColors: true,
|
||||
}
|
||||
|
||||
const consoleREPL: CliCommand = async () => {
|
||||
process.env.CLI_COMMAND_CONSOLE = "true"
|
||||
log.branded("You have entered the Blitz console")
|
||||
console.log(chalk.yellow("Tips: - Exit by typing .exit or pressing Ctrl-D"))
|
||||
console.log(chalk.yellow(` - Use your db like this: ${getDbFolder()}.project.findMany()`))
|
||||
console.log(chalk.yellow(" - Use your queries/mutations like this: getProjects({})"))
|
||||
|
||||
const {register} = require("esbuild-register/dist/node")
|
||||
|
||||
const {unregister} = register({
|
||||
target: "es6",
|
||||
})
|
||||
|
||||
const onlyDb = args["--only-db"] as boolean
|
||||
if (onlyDb) {
|
||||
console.log(chalk.green(`Loading only ${getDbFolder()} module`))
|
||||
}
|
||||
await runRepl(replOptions, onlyDb)
|
||||
|
||||
unregister()
|
||||
}
|
||||
|
||||
export {consoleREPL}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user