Compare commits
12 Commits
blitz@2.0.
...
@blitzjs/g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9631c45833 | ||
|
|
2150dcc3e7 | ||
|
|
63605961b4 | ||
|
|
d711948809 | ||
|
|
1f6b0b54c2 | ||
|
|
4603a2b7bd | ||
|
|
01f3a03ea9 | ||
|
|
36e26193b7 | ||
|
|
4a9aa9f7ff | ||
|
|
1e1bb73b2d | ||
|
|
99205f52d5 | ||
|
|
d03a1165d7 |
7
.changeset/breezy-cameras-double.md
Normal file
7
.changeset/breezy-cameras-double.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Fix codegen and postinstall to make work with pnpm
|
||||
6
.changeset/dirty-monkeys-greet.md
Normal file
6
.changeset/dirty-monkeys-greet.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Use alpha version for blitz dependency, fix package manager selection
|
||||
5
.changeset/empty-berries-rule.md
Normal file
5
.changeset/empty-berries-rule.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
fix app generator for pnpm unmet dependency
|
||||
5
.changeset/fair-wombats-sneeze.md
Normal file
5
.changeset/fair-wombats-sneeze.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
added superjson
|
||||
5
.changeset/flat-bees-approve.md
Normal file
5
.changeset/flat-bees-approve.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
set default enviornment variable to development unless build and start command
|
||||
5
.changeset/poor-shrimps-think.md
Normal file
5
.changeset/poor-shrimps-think.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": patch
|
||||
---
|
||||
|
||||
Setup SuperJson for GSSP and GSP
|
||||
@@ -2,30 +2,40 @@
|
||||
"mode": "pre",
|
||||
"tag": "alpha",
|
||||
"initialVersions": {
|
||||
"toolkit-app": "1.0.1-alpha.13",
|
||||
"web": "0.0.0",
|
||||
"test-auth": "0.0.0",
|
||||
"test-rpc": "0.0.0",
|
||||
"test-utils": "0.0.0",
|
||||
"blitz": "2.0.0-alpha.0",
|
||||
"@blitzjs/auth": "2.0.0-alpha.0",
|
||||
"@blitzjs/next": "2.0.0-alpha.0",
|
||||
"@blitzjs/rpc": "2.0.0-alpha.0",
|
||||
"@blitzjs/config": "0.0.0",
|
||||
"@blitzjs/generator": "2.0.0-alpha.0",
|
||||
"template": "0.0.0",
|
||||
"toolkit-app": "1.0.0"
|
||||
"blitz": "2.0.0-alpha.18",
|
||||
"@blitzjs/auth": "2.0.0-alpha.18",
|
||||
"@blitzjs/next": "2.0.0-alpha.18",
|
||||
"@blitzjs/rpc": "2.0.0-alpha.18",
|
||||
"@blitzjs/config": "2.0.0-alpha.18",
|
||||
"@blitzjs/generator": "2.0.0-alpha.18",
|
||||
"template": "0.0.0"
|
||||
},
|
||||
"changesets": [
|
||||
"breezy-cameras-double",
|
||||
"dirty-monkeys-greet",
|
||||
"empty-berries-rule",
|
||||
"fair-wombats-sneeze",
|
||||
"flat-bees-approve",
|
||||
"great-months-train",
|
||||
"lovely-colts-share",
|
||||
"nine-onions-admire",
|
||||
"ninety-pets-heal",
|
||||
"poor-peas-lick",
|
||||
"poor-shrimps-think",
|
||||
"quiet-feet-travel",
|
||||
"sharp-falcons-begin",
|
||||
"silent-colts-reply",
|
||||
"swift-drinks-dress",
|
||||
"ten-rivers-burn",
|
||||
"thirty-countries-build",
|
||||
"twenty-beans-pump"
|
||||
"twenty-beans-pump",
|
||||
"two-kiwis-help",
|
||||
"unlucky-papayas-sleep",
|
||||
"wicked-ghosts-cough"
|
||||
]
|
||||
}
|
||||
|
||||
5
.changeset/sharp-falcons-begin.md
Normal file
5
.changeset/sharp-falcons-begin.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Use routes manifest in template app
|
||||
5
.changeset/two-kiwis-help.md
Normal file
5
.changeset/two-kiwis-help.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
fix generate cli command
|
||||
5
.changeset/unlucky-papayas-sleep.md
Normal file
5
.changeset/unlucky-papayas-sleep.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
remove console logs inside onPostInstall in the new cli command
|
||||
5
.changeset/wicked-ghosts-cough.md
Normal file
5
.changeset/wicked-ghosts-cough.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
fix template sourcepath because of new env variable
|
||||
@@ -1,5 +1,92 @@
|
||||
# toolkit-app
|
||||
|
||||
## 1.0.1-alpha.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- Updated dependencies [2150dcc3]
|
||||
- @blitzjs/next@2.0.0-alpha.19
|
||||
- blitz@2.0.0-alpha.19
|
||||
- @blitzjs/auth@2.0.0-alpha.19
|
||||
- @blitzjs/rpc@2.0.0-alpha.19
|
||||
- @blitzjs/config@2.0.0-alpha.19
|
||||
|
||||
## 1.0.1-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.18
|
||||
- @blitzjs/auth@2.0.0-alpha.18
|
||||
- @blitzjs/next@2.0.0-alpha.18
|
||||
- @blitzjs/rpc@2.0.0-alpha.18
|
||||
- @blitzjs/config@2.0.0-alpha.18
|
||||
|
||||
## 1.0.1-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.17
|
||||
- @blitzjs/auth@2.0.0-alpha.17
|
||||
- @blitzjs/next@2.0.0-alpha.17
|
||||
- @blitzjs/rpc@2.0.0-alpha.17
|
||||
- @blitzjs/config@2.0.0-alpha.17
|
||||
|
||||
## 1.0.1-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.16
|
||||
- @blitzjs/auth@2.0.0-alpha.16
|
||||
- @blitzjs/next@2.0.0-alpha.16
|
||||
- @blitzjs/rpc@2.0.0-alpha.16
|
||||
- @blitzjs/config@2.0.0-alpha.16
|
||||
|
||||
## 1.0.1-alpha.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.15
|
||||
- @blitzjs/auth@2.0.0-alpha.15
|
||||
- @blitzjs/next@2.0.0-alpha.15
|
||||
- @blitzjs/rpc@2.0.0-alpha.15
|
||||
- @blitzjs/config@2.0.0-alpha.15
|
||||
|
||||
## 1.0.1-alpha.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.14
|
||||
- @blitzjs/auth@2.0.0-alpha.14
|
||||
- @blitzjs/next@2.0.0-alpha.14
|
||||
- @blitzjs/rpc@2.0.0-alpha.14
|
||||
- @blitzjs/config@2.0.0-alpha.14
|
||||
|
||||
## 1.0.1-alpha.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.13
|
||||
- @blitzjs/next@2.0.0-alpha.13
|
||||
- @blitzjs/auth@2.0.0-alpha.13
|
||||
- @blitzjs/rpc@2.0.0-alpha.13
|
||||
- @blitzjs/config@2.0.0-alpha.13
|
||||
|
||||
## 1.0.1-alpha.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.12
|
||||
- @blitzjs/auth@2.0.0-alpha.12
|
||||
- @blitzjs/next@2.0.0-alpha.12
|
||||
- @blitzjs/rpc@2.0.0-alpha.12
|
||||
- @blitzjs/config@2.0.0-alpha.12
|
||||
|
||||
## 1.0.1-alpha.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Form, FORM_ERROR } from "app/core/components/Form"
|
||||
import login from "app/auth/mutations/login"
|
||||
import { Login } from "app/auth/validations"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
type LoginFormProps = {
|
||||
onSuccess?: (user: PromiseReturnType<typeof login>) => void
|
||||
@@ -39,7 +40,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
<LabeledTextField name="email" label="Email" placeholder="Email" />
|
||||
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
|
||||
<div>
|
||||
<Link href="/auth/forgot-password" passHref>
|
||||
<Link href={Routes.ForgotPasswordPage()} passHref>
|
||||
<a>Forgot your password?</a>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -47,7 +48,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
|
||||
<div style={{ marginTop: "1rem" }}>
|
||||
Or{" "}
|
||||
<Link href="/auth/signup" passHref>
|
||||
<Link href={Routes.SignupPage()} passHref>
|
||||
<a>Sign Up</a>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
47
apps/toolkit-app/db/migrations/20220427214932_/migration.sql
Normal file
47
apps/toolkit-app/db/migrations/20220427214932_/migration.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
"name" TEXT,
|
||||
"email" TEXT NOT NULL,
|
||||
"hashedPassword" TEXT,
|
||||
"role" TEXT NOT NULL DEFAULT 'USER'
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Session" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
"expiresAt" DATETIME,
|
||||
"handle" TEXT NOT NULL,
|
||||
"hashedSessionToken" TEXT,
|
||||
"antiCSRFToken" TEXT,
|
||||
"publicData" TEXT,
|
||||
"privateData" TEXT,
|
||||
"userId" INTEGER,
|
||||
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Token" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
"hashedToken" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"expiresAt" DATETIME NOT NULL,
|
||||
"sentTo" TEXT NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Session_handle_key" ON "Session"("handle");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Token_hashedToken_type_key" ON "Token"("hashedToken", "type");
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "toolkit-app",
|
||||
"version": "1.0.1-alpha.6",
|
||||
"version": "1.0.1-alpha.14",
|
||||
"scripts": {
|
||||
"start:dev": "pnpm run prisma:start && next dev",
|
||||
"buildapp": "prisma generate && next build",
|
||||
"buildapp": "pnpm i && pnpm prisma generate && next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"prisma:start": "prisma generate && prisma migrate deploy",
|
||||
@@ -29,8 +29,8 @@
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@hookform/resolvers": "2.8.8",
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:2.0.0-alpha.11",
|
||||
"next": "12.1.1",
|
||||
"blitz": "workspace:2.0.0-alpha.19",
|
||||
"next": "12.1.6-canary.17",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useRouter } from "next/router"
|
||||
import Layout from "app/core/layouts/Layout"
|
||||
import { SignupForm } from "app/auth/components/SignupForm"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
const SignupPage = () => {
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<Layout title="Sign Up">
|
||||
<SignupForm onSuccess={() => router.push("/")} />
|
||||
<SignupForm onSuccess={() => router.push(Routes.Home())} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useCurrentUser } from "app/core/hooks/useCurrentUser"
|
||||
import logout from "app/auth/mutations/logout"
|
||||
import logo from "public/logo.png"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
/*
|
||||
* This file is just for a pleasant getting started page for your new app.
|
||||
@@ -37,12 +38,12 @@ const UserInfo = () => {
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Link href="/auth/signup" passHref>
|
||||
<Link href={Routes.SignupPage()} passHref>
|
||||
<a className="button small">
|
||||
<strong>Sign Up</strong>
|
||||
</a>
|
||||
</Link>
|
||||
<Link href="/auth/login" passHref>
|
||||
<Link href={Routes.LoginPage()} passHref>
|
||||
<a className="button small">
|
||||
<strong>Login</strong>
|
||||
</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"baseUrl": "./",
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"@types/jest": "27.4.1",
|
||||
"blitz": "workspace:*",
|
||||
"jest": "27.5.1",
|
||||
"next": "12.1.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import {gSP} from "app/blitz-server"
|
||||
|
||||
export const getStaticProps = gSP(async ({ctx}) => {
|
||||
export const getStaticProps = gSP<{data: {test: string}}>(async ({ctx}) => {
|
||||
return {
|
||||
props: {
|
||||
data: {
|
||||
// userId: ctx?.session.userId,
|
||||
// session: {
|
||||
// id: session.userId,
|
||||
// publicData: session.$publicData,
|
||||
// },
|
||||
test: "hello",
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export const getServerSideProps = gSSP<Props>(async ({ctx}) => {
|
||||
props: {
|
||||
userId: session.userId,
|
||||
publicData: session.$publicData,
|
||||
publishedAt: new Date(0)
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"@prisma/client": "3.9.0",
|
||||
"blitz": "workspace:*",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.1.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"prisma": "3.9.0",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"blitz": "workspace:*",
|
||||
"next": "12.1.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0"
|
||||
},
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"husky": "7.0.4",
|
||||
"jsdom": "19.0.0",
|
||||
"lint-staged": "12.1.7",
|
||||
"next": "12.1.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"only-allow": "1.1.0",
|
||||
"patch-package": "6.4.7",
|
||||
"prettier": "^2.5.1",
|
||||
|
||||
@@ -1,5 +1,58 @@
|
||||
# @blitzjs/auth
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.19
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.17
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.12
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/auth",
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts",
|
||||
@@ -24,7 +24,7 @@
|
||||
"@types/secure-password": "3.1.1",
|
||||
"b64-lite": "1.4.0",
|
||||
"bad-behavior": "1.0.1",
|
||||
"blitz": "2.0.0-alpha.11",
|
||||
"blitz": "2.0.0-alpha.19",
|
||||
"cookie": "0.4.1",
|
||||
"debug": "4.3.3",
|
||||
"http": "0.0.1-security",
|
||||
@@ -35,7 +35,7 @@
|
||||
"url": "0.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.11",
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.19",
|
||||
"@testing-library/react": "13.0.0",
|
||||
"@testing-library/react-hooks": "7.0.2",
|
||||
"@types/cookie": "0.4.1",
|
||||
|
||||
@@ -138,7 +138,10 @@ export const useSession = (options: UseSessionOptions = {}): ClientSession => {
|
||||
initialState = {...options.initialPublicData, isLoading: false}
|
||||
} else if (suspense) {
|
||||
if (isServer) {
|
||||
throw new Promise((_) => {})
|
||||
const e = new Error()
|
||||
e.name = "Rendering Suspense fallback..."
|
||||
delete e.stack
|
||||
throw e
|
||||
} else {
|
||||
initialState = {...getPublicDataStore().getData(), isLoading: false}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
# @blitzjs/next
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- added superjson
|
||||
- 2150dcc3: Setup SuperJson for GSSP and GSP
|
||||
- @blitzjs/rpc@2.0.0-alpha.19
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.17
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix codegen and postinstall to make work with pnpm
|
||||
- @blitzjs/rpc@2.0.0-alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @blitzjs/rpc@2.0.0-alpha.12
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/next",
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "pnpm predev && pnpm watch unbuild src --wait=0.2",
|
||||
@@ -23,13 +23,16 @@
|
||||
"eslint.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@blitzjs/rpc": "2.0.0-alpha.11",
|
||||
"@blitzjs/rpc": "2.0.0-alpha.19",
|
||||
"@types/hoist-non-react-statics": "3.3.1",
|
||||
"debug": "4.3.3",
|
||||
"fs-extra": "10.0.1",
|
||||
"react-query": "3.21.1"
|
||||
"hoist-non-react-statics": "3.3.2",
|
||||
"react-query": "3.21.1",
|
||||
"superjson": "1.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.11",
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.19",
|
||||
"@testing-library/dom": "8.13.0",
|
||||
"@testing-library/jest-dom": "5.16.3",
|
||||
"@testing-library/react": "13.0.0",
|
||||
@@ -40,11 +43,11 @@
|
||||
"@types/react": "17.0.43",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"@types/testing-library__react-hooks": "4.0.0",
|
||||
"blitz": "2.0.0-alpha.11",
|
||||
"blitz": "2.0.0-alpha.19",
|
||||
"cross-spawn": "7.0.3",
|
||||
"find-up": "4.1.0",
|
||||
"lodash.frompairs": "4.0.1",
|
||||
"next": "12.1.1",
|
||||
"next": "12.1.6-canary.17",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
"resolve-from": "5.0.0",
|
||||
|
||||
@@ -27,6 +27,16 @@ async function findNodeModulesRoot(src) {
|
||||
let root
|
||||
if (isInBlitzMonorepo) {
|
||||
root = path.join(src, "node_modules")
|
||||
} else if (src.includes(".pnpm")) {
|
||||
const blitzPkgLocation = path.dirname(
|
||||
(await findUp("package.json", {
|
||||
cwd: resolveFrom(src, "blitz"),
|
||||
})) || "",
|
||||
)
|
||||
if (!blitzPkgLocation) {
|
||||
throw new Error("Internal Blitz Error: unable to find 'blitz' package location")
|
||||
}
|
||||
root = path.join(blitzPkgLocation, "../../../../")
|
||||
} else {
|
||||
const blitzPkgLocation = path.dirname(
|
||||
(await findUp("package.json", {
|
||||
@@ -96,7 +106,11 @@ function codegen() {
|
||||
const packagePath = require.resolve("blitz/package.json")
|
||||
if (packagePath) {
|
||||
const blitzPkg = require.resolve("blitz/dist/index.cjs")
|
||||
return path.join(blitzPkg)
|
||||
if (blitzPkg.includes(".pnpm")) {
|
||||
return path.join(blitzPkg, "../../../../../../blitz/dist/index.cjs")
|
||||
} else {
|
||||
return path.join(blitzPkg)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
@@ -323,6 +337,6 @@ function codegen() {
|
||||
const UNABLE_TO_FIND_POSTINSTALL_TRIGGER_JSON_SCHEMA_ERROR = 'UNABLE_TO_FIND_POSTINSTALL_TRIGGER_JSON_SCHEMA_ERROR'
|
||||
}
|
||||
|
||||
if (!isInstalledGlobally) {
|
||||
codegen()
|
||||
}
|
||||
// if (!isInstalledGlobally) {
|
||||
codegen()
|
||||
// }
|
||||
|
||||
@@ -10,6 +10,7 @@ import Head from "next/head"
|
||||
import React from "react"
|
||||
import {QueryClient, QueryClientProvider} from "react-query"
|
||||
import {Hydrate, HydrateOptions} from "react-query/hydration"
|
||||
import {withSuperJSONPage} from './superjson'
|
||||
|
||||
export * from "./error-boundary"
|
||||
export * from "./error-component"
|
||||
@@ -47,7 +48,7 @@ const buildWithBlitz = <TPlugins extends readonly ClientPlugin<object>[]>(plugin
|
||||
</BlitzProvider>
|
||||
)
|
||||
}
|
||||
return BlitzOuterRoot
|
||||
return withSuperJSONPage(BlitzOuterRoot)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {GetServerSideProps, GetStaticProps, NextApiRequest, NextApiResponse} from "next"
|
||||
import type {Ctx as BlitzCtx, BlitzServerPlugin, Middleware, MiddlewareResponse} from "blitz"
|
||||
import {handleRequestWithMiddleware} from "blitz"
|
||||
import {withSuperJSONPropsGsp, withSuperJSONPropsGssp} from "./superjson"
|
||||
|
||||
export * from "./index-browser"
|
||||
|
||||
@@ -27,10 +28,10 @@ export type BlitzGSSPHandler<TProps> = ({
|
||||
...args
|
||||
}: Parameters<GetServerSideProps<TProps>>[0] & {ctx: Ctx}) => ReturnType<GetServerSideProps<TProps>>
|
||||
|
||||
export type BlitzGSPHandler = ({
|
||||
export type BlitzGSPHandler<TProps> = ({
|
||||
ctx,
|
||||
...args
|
||||
}: Parameters<GetStaticProps>[0] & {ctx: Ctx}) => ReturnType<GetServerSideProps>
|
||||
}: Parameters<GetStaticProps<TProps>>[0] & {ctx: Ctx}) => ReturnType<GetStaticProps<TProps>>
|
||||
|
||||
export type BlitzAPIHandler = (
|
||||
req: Parameters<NextApiHandler>[0],
|
||||
@@ -42,23 +43,21 @@ export const setupBlitzServer = ({plugins}: SetupBlitzOptions) => {
|
||||
const middlewares = plugins.flatMap((p) => p.middlewares)
|
||||
const contextMiddleware = plugins.flatMap((p) => p.contextMiddleware).filter(Boolean)
|
||||
|
||||
const gSSP =
|
||||
<TProps>(handler: BlitzGSSPHandler<TProps>): GetServerSideProps<TProps> =>
|
||||
async ({req, res, ...rest}) => {
|
||||
const gSSP = <TProps>(handler: BlitzGSSPHandler<TProps>): GetServerSideProps<TProps> =>
|
||||
withSuperJSONPropsGssp<TProps>(async ({req, res, ...rest}) => {
|
||||
await handleRequestWithMiddleware(req, res, middlewares)
|
||||
const ctx = contextMiddleware.reduceRight(
|
||||
(y, f) => (f ? f(y) : y),
|
||||
(res as MiddlewareResponse).blitzCtx,
|
||||
)
|
||||
return handler({req, res, ctx, ...rest})
|
||||
}
|
||||
})
|
||||
|
||||
const gSP =
|
||||
(handler: BlitzGSPHandler): GetStaticProps =>
|
||||
async (context) => {
|
||||
const gSP = <TProps>(handler: BlitzGSPHandler<TProps>): GetStaticProps<TProps> =>
|
||||
withSuperJSONPropsGsp<TProps>(async (context) => {
|
||||
const ctx = contextMiddleware.reduceRight((y, f) => (f ? f(y) : y), {} as Ctx)
|
||||
return handler({...context, ctx: ctx})
|
||||
}
|
||||
})
|
||||
|
||||
const api =
|
||||
(handler: BlitzAPIHandler): NextApiHandler =>
|
||||
|
||||
89
packages/blitz-next/src/superjson.tsx
Normal file
89
packages/blitz-next/src/superjson.tsx
Normal file
@@ -0,0 +1,89 @@
|
||||
import hoistNonReactStatics from "hoist-non-react-statics"
|
||||
import type {
|
||||
GetServerSideProps,
|
||||
GetServerSidePropsResult,
|
||||
GetStaticProps,
|
||||
GetStaticPropsResult,
|
||||
} from "next"
|
||||
import * as React from "react"
|
||||
import SuperJSON from "superjson"
|
||||
|
||||
export type SuperJSONProps<P = any> = P & {
|
||||
_superjson?: any
|
||||
}
|
||||
|
||||
function excludeProps<P>(
|
||||
result: GetServerSidePropsResult<P> | GetStaticPropsResult<P>,
|
||||
exclude: string[] = [],
|
||||
) {
|
||||
if (!("props" in result)) {
|
||||
return result
|
||||
}
|
||||
|
||||
if (!result.props) {
|
||||
return result
|
||||
}
|
||||
|
||||
const excludedPropValues = exclude.map((propKey) => {
|
||||
const value = (result.props as any)[propKey]
|
||||
delete (result.props as any)[propKey]
|
||||
return value
|
||||
})
|
||||
|
||||
const {json, meta} = SuperJSON.serialize(result.props)
|
||||
const props = json as any
|
||||
|
||||
if (meta) {
|
||||
props._superjson = meta
|
||||
}
|
||||
|
||||
exclude.forEach((key, index) => {
|
||||
const excludedPropValue = excludedPropValues[index]
|
||||
if (typeof excludedPropValue !== "undefined") {
|
||||
props[key] = excludedPropValue
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
...result,
|
||||
props,
|
||||
}
|
||||
}
|
||||
|
||||
export function withSuperJSONPropsGssp<P>(
|
||||
handler: GetServerSideProps<P>,
|
||||
exclude: string[] = [],
|
||||
): GetServerSideProps<SuperJSONProps<P>> {
|
||||
return async function withSuperJSON(...args) {
|
||||
const result = await handler(...args)
|
||||
return excludeProps(result, exclude)
|
||||
}
|
||||
}
|
||||
|
||||
export function withSuperJSONPropsGsp<P>(
|
||||
handler: GetStaticProps<P>,
|
||||
exclude: string[] = [],
|
||||
): GetStaticProps<P> {
|
||||
return async function withSuperJSON(...args) {
|
||||
const result = await handler(...args)
|
||||
|
||||
return excludeProps<any>(result, exclude)
|
||||
}
|
||||
}
|
||||
|
||||
export function deserializeProps<P>(serializedProps: SuperJSONProps<P>): P {
|
||||
const {_superjson, ...props} = serializedProps
|
||||
return SuperJSON.deserialize({json: props as any, meta: _superjson})
|
||||
}
|
||||
|
||||
export function withSuperJSONPage<P>(
|
||||
Page: React.ComponentType<P>,
|
||||
): React.ComponentType<SuperJSONProps<P>> {
|
||||
function WithSuperJSON(serializedProps: SuperJSONProps<P>) {
|
||||
return <Page {...deserializeProps<P>(serializedProps)} />
|
||||
}
|
||||
|
||||
hoistNonReactStatics(WithSuperJSON, Page)
|
||||
|
||||
return WithSuperJSON
|
||||
}
|
||||
@@ -1,5 +1,66 @@
|
||||
# @blitzjs/rpc
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.19
|
||||
- @blitzjs/auth@2.0.0-alpha.19
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.18
|
||||
- @blitzjs/auth@2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.17
|
||||
- @blitzjs/auth@2.0.0-alpha.17
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.16
|
||||
- @blitzjs/auth@2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- blitz@2.0.0-alpha.15
|
||||
- @blitzjs/auth@2.0.0-alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.14
|
||||
- @blitzjs/auth@2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.13
|
||||
- @blitzjs/auth@2.0.0-alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- blitz@2.0.0-alpha.12
|
||||
- @blitzjs/auth@2.0.0-alpha.12
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/rpc",
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"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",
|
||||
@@ -20,7 +20,7 @@
|
||||
"dist/**"
|
||||
],
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "2.0.0-alpha.11",
|
||||
"@blitzjs/auth": "2.0.0-alpha.19",
|
||||
"b64-lite": "1.4.0",
|
||||
"bad-behavior": "1.0.1",
|
||||
"chalk": "^4.1.0",
|
||||
@@ -30,12 +30,12 @@
|
||||
"zod": "3.10.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.11",
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.19",
|
||||
"@types/debug": "4.1.7",
|
||||
"@types/react": "17.0.43",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"blitz": "2.0.0-alpha.11",
|
||||
"next": "12.1.1",
|
||||
"blitz": "2.0.0-alpha.19",
|
||||
"next": "12.1.6-canary.17",
|
||||
"react": "18.0.0",
|
||||
"react-dom": "18.0.0",
|
||||
"typescript": "^4.5.3",
|
||||
@@ -43,7 +43,7 @@
|
||||
"watch": "1.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"blitz": "2.0.0-alpha.11",
|
||||
"blitz": "2.0.0-alpha.19",
|
||||
"next": "*"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -99,7 +99,10 @@ export function useQuery<
|
||||
(!options || !("suspense" in options) || options.suspense) &&
|
||||
(!options || !("enabled" in options) || options.enabled)
|
||||
) {
|
||||
throw new Promise(() => {})
|
||||
const e = new Error()
|
||||
e.name = "Rendering Suspense fallback..."
|
||||
delete e.stack
|
||||
throw e
|
||||
}
|
||||
|
||||
const rest = {
|
||||
@@ -182,7 +185,10 @@ export function usePaginatedQuery<
|
||||
(!options || !("suspense" in options) || options.suspense) &&
|
||||
(!options || !("enabled" in options) || options.enabled)
|
||||
) {
|
||||
throw new Promise(() => {})
|
||||
const e = new Error()
|
||||
e.name = "Rendering Suspense fallback..."
|
||||
delete e.stack
|
||||
throw e
|
||||
}
|
||||
|
||||
const rest = {
|
||||
@@ -278,7 +284,10 @@ export function useInfiniteQuery<
|
||||
(!options || !("suspense" in options) || options.suspense) &&
|
||||
(!options || !("enabled" in options) || options.enabled)
|
||||
) {
|
||||
throw new Promise(() => {})
|
||||
const e = new Error()
|
||||
e.name = "Rendering Suspense fallback..."
|
||||
delete e.stack
|
||||
throw e
|
||||
}
|
||||
|
||||
const rest = {
|
||||
|
||||
@@ -1,5 +1,63 @@
|
||||
# blitz
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [63605961]
|
||||
- @blitzjs/generator@2.0.0-alpha.19
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix generate cli command
|
||||
- @blitzjs/generator@2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @blitzjs/generator@2.0.0-alpha.17
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- remove console logs inside onPostInstall in the new cli command
|
||||
- @blitzjs/generator@2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @blitzjs/generator@2.0.0-alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- set default enviornment variable to development unless build and start command
|
||||
- @blitzjs/generator@2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix codegen and postinstall to make work with pnpm
|
||||
- Updated dependencies
|
||||
- @blitzjs/generator@2.0.0-alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Use alpha version for blitz dependency, fix package manager selection
|
||||
- Updated dependencies
|
||||
- @blitzjs/generator@2.0.0-alpha.12
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -2,7 +2,7 @@ import {BuildConfig} from "unbuild"
|
||||
|
||||
const config: BuildConfig = {
|
||||
entries: ["./src/index-browser", "./src/index-server", "./src/cli/index"],
|
||||
externals: ["index-browser.cjs", "index-browser.mjs", "index.cjs", "zod", "@blitzjs/generator"],
|
||||
externals: ["index-browser.cjs", "index-browser.mjs", "index.cjs", "zod"],
|
||||
declaration: true,
|
||||
rollup: {
|
||||
emitCJS: true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "blitz",
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "watch unbuild src --wait=0.2",
|
||||
@@ -23,7 +23,7 @@
|
||||
"blitz": "bin/blitz"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/generator": "2.0.0-alpha.11",
|
||||
"@blitzjs/generator": "2.0.0-alpha.19",
|
||||
"arg": "5.0.1",
|
||||
"chalk": "^4.1.0",
|
||||
"console-table-printer": "2.10.0",
|
||||
@@ -47,7 +47,7 @@
|
||||
"tslog": "3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.11",
|
||||
"@blitzjs/config": "workspace:2.0.0-alpha.19",
|
||||
"@types/cookie": "0.4.1",
|
||||
"@types/cross-spawn": "6.0.2",
|
||||
"@types/debug": "4.1.7",
|
||||
|
||||
@@ -133,8 +133,9 @@ const validateModelName = (modelName: string): void => {
|
||||
|
||||
const determineType = async () => {
|
||||
if (
|
||||
!args["--type"] ||
|
||||
(args["--type"] && !Object.keys(generatorMap).includes(args["--type"].toLowerCase()))
|
||||
!args["_"].slice(1)[0] ||
|
||||
(args["_"].slice(1)[0] &&
|
||||
!Object.keys(generatorMap).includes(args["_"].slice(1)[0]?.toLowerCase() as string))
|
||||
) {
|
||||
const res = await prompts({
|
||||
type: "select",
|
||||
@@ -148,12 +149,12 @@ const determineType = async () => {
|
||||
|
||||
selectedType = res.type
|
||||
} else {
|
||||
selectedType = args["--type"]
|
||||
selectedType = args["_"].slice(1)[0]?.toLowerCase() as string
|
||||
}
|
||||
}
|
||||
|
||||
const determineName = async () => {
|
||||
if (!args["--name"]) {
|
||||
if (!args["_"].slice(1)[1]) {
|
||||
const res = await prompts({
|
||||
type: "text",
|
||||
name: "model",
|
||||
@@ -164,7 +165,7 @@ const determineName = async () => {
|
||||
selectedModelName = model
|
||||
selectedContext = context
|
||||
} else {
|
||||
const {model, context} = getModelNameAndContext(args["--name"])
|
||||
const {model, context} = getModelNameAndContext(args["_"].slice(1)[1]!)
|
||||
selectedModelName = model
|
||||
selectedContext = context
|
||||
}
|
||||
@@ -249,7 +250,7 @@ const generate: CliCommand = async (argv) => {
|
||||
const generator = new GeneratorClass({
|
||||
destinationRoot: require("path").resolve(),
|
||||
// templateDir: blitzConfig.codegen?.templateDir,
|
||||
extraArgs: args["_"].slice(1) as string[],
|
||||
extraArgs: args["_"].slice(3) as string[],
|
||||
modelName: singularRootContext,
|
||||
modelNames: modelNames(singularRootContext),
|
||||
ModelName: ModelName(singularRootContext),
|
||||
|
||||
@@ -193,13 +193,15 @@ const determinePkgManagerToInstallDeps = async () => {
|
||||
message: "Install dependencies?",
|
||||
initial: 0,
|
||||
choices: [
|
||||
{title: "npm"},
|
||||
{title: "yarn", disabled: !IS_YARN_INSTALLED},
|
||||
{title: "pnpm", disabled: !IS_PNPM_INSTALLED},
|
||||
{title: "npm", value: "npm"},
|
||||
{title: "yarn", value: "yarn", disabled: !IS_YARN_INSTALLED},
|
||||
{title: "pnpm", value: "pnpm", disabled: !IS_PNPM_INSTALLED},
|
||||
{title: "skip"},
|
||||
],
|
||||
})
|
||||
|
||||
projectPkgManger = res.pkgManager
|
||||
|
||||
if (res.pkgManager === "skip") {
|
||||
shouldInstallDeps = false
|
||||
} else {
|
||||
@@ -262,7 +264,6 @@ const newApp: CliCommand = async (argv) => {
|
||||
{ignoreCache: true},
|
||||
)
|
||||
const result = await runPrisma(["migrate", "dev", "--name", "Initial migration"], true)
|
||||
console.log("primsa result", result)
|
||||
if (!result.success) throw new Error()
|
||||
} catch (error) {
|
||||
postInstallSteps.push(
|
||||
|
||||
@@ -58,7 +58,8 @@ if (args["--help"]) {
|
||||
forwardedArgs.push("--help")
|
||||
}
|
||||
|
||||
const defaultEnv = command === "dev" ? "development" : "production"
|
||||
// env variable should default to dev unless the command is build or start
|
||||
const defaultEnv = command === "build" || command === "start" ? "production" : "development"
|
||||
|
||||
const standardEnv = ["production", "development", "test"]
|
||||
if (process.env.NODE_ENV && !standardEnv.includes(process.env.NODE_ENV)) {
|
||||
|
||||
@@ -538,7 +538,11 @@ async function findNodeModulesRoot(src: string) {
|
||||
throw new Error("Internal Blitz Error: unable to find 'blitz' package location")
|
||||
}
|
||||
|
||||
root = join(blitzPkgLocation, "../")
|
||||
if (blitzPkgLocation.includes(".pnpm")) {
|
||||
root = join(blitzPkgLocation, "../../../../")
|
||||
} else {
|
||||
root = join(blitzPkgLocation, "../")
|
||||
}
|
||||
}
|
||||
|
||||
return root
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# @blitzjs/config
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
## 2.0.0-alpha.10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@blitzjs/config",
|
||||
"private": true,
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "5.9.1",
|
||||
|
||||
@@ -1,5 +1,41 @@
|
||||
# @blitzjs/generator
|
||||
|
||||
## 2.0.0-alpha.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 63605961: Use routes manifest in template app
|
||||
|
||||
## 2.0.0-alpha.18
|
||||
|
||||
## 2.0.0-alpha.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix app generator for pnpm unmet dependency
|
||||
|
||||
## 2.0.0-alpha.16
|
||||
|
||||
## 2.0.0-alpha.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fix template sourcepath because of new env variable
|
||||
|
||||
## 2.0.0-alpha.14
|
||||
|
||||
## 2.0.0-alpha.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix codegen and postinstall to make work with pnpm
|
||||
|
||||
## 2.0.0-alpha.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Use alpha version for blitz dependency, fix package manager selection
|
||||
|
||||
## 2.0.0-alpha.11
|
||||
|
||||
## 2.0.0-alpha.10
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/generator",
|
||||
"version": "2.0.0-alpha.11",
|
||||
"version": "2.0.0-alpha.19",
|
||||
"scripts": {
|
||||
"dev": "watch unbuild src --wait=0.2",
|
||||
"build": "unbuild && pnpm build:templates",
|
||||
@@ -45,7 +45,7 @@
|
||||
"vinyl": "2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "2.0.0-alpha.11",
|
||||
"@blitzjs/config": "2.0.0-alpha.19",
|
||||
"@juanm04/cpx": "2.0.1",
|
||||
"@types/babel__core": "7.1.19",
|
||||
"@types/diff": "5.0.2",
|
||||
|
||||
@@ -302,7 +302,7 @@ export abstract class Generator<
|
||||
return path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
process.env.NODE_ENV === "test" ? "../templates" : "./dist/templates",
|
||||
process.env.NODE_ENV === "test" ? "./templates" : "./dist/templates",
|
||||
this.sourceRoot.path,
|
||||
...paths,
|
||||
)
|
||||
|
||||
@@ -111,7 +111,7 @@ export class AppGenerator extends Generator<AppGeneratorOptions> {
|
||||
const [
|
||||
{value: newDependencies, isFallback: dependenciesUsedFallback},
|
||||
{value: newDevDependencies, isFallback: devDependenciesUsedFallback},
|
||||
{value: blitzDependencyVersion, isFallback: blitzUsedFallback},
|
||||
{value: blitzDependencyVersion},
|
||||
] = await Promise.all([
|
||||
fetchLatestVersionsFor(pkg.dependencies),
|
||||
fetchLatestVersionsFor(pkg.devDependencies),
|
||||
@@ -122,8 +122,7 @@ export class AppGenerator extends Generator<AppGeneratorOptions> {
|
||||
pkg.devDependencies = newDevDependencies
|
||||
pkg.dependencies.blitz = blitzDependencyVersion
|
||||
|
||||
const fallbackUsed =
|
||||
dependenciesUsedFallback || devDependenciesUsedFallback || blitzUsedFallback
|
||||
const fallbackUsed = dependenciesUsedFallback || devDependenciesUsedFallback
|
||||
|
||||
await writeJson(pkgJsonLocation, pkg, {spaces: 2})
|
||||
|
||||
@@ -156,6 +155,12 @@ export class AppGenerator extends Generator<AppGeneratorOptions> {
|
||||
cp.stdout?.setEncoding("utf8")
|
||||
cp.stderr?.setEncoding("utf8")
|
||||
cp.stdout?.on("data", (data) => {
|
||||
if (pkgManager === "pnpm") {
|
||||
if (data.includes("ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies")) {
|
||||
spinners[spinners.length - 1]?.succeed()
|
||||
}
|
||||
}
|
||||
|
||||
if (pkgManager === "yarn") {
|
||||
let json = getJSON(data)
|
||||
if (json && json.type === "step") {
|
||||
@@ -235,14 +240,6 @@ export class AppGenerator extends Generator<AppGeneratorOptions> {
|
||||
}
|
||||
}
|
||||
|
||||
// if(this.options.useTs) {
|
||||
// if(templatedPathSuffix === "pages/api/rpc/blitzrpcroute.js") {
|
||||
// this.fs.write(this.destinationPath("pages/api/rpc/[...blitz].js"), this.sourcePath("pages/api/rpc/blitzrpcroute.js"))
|
||||
// } else {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!this.options.skipGit && gitInitSuccessful) {
|
||||
this.commitChanges()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface Fallbackable<T> {
|
||||
value: T
|
||||
isFallback: boolean
|
||||
isFallback?: boolean
|
||||
}
|
||||
|
||||
@@ -6,16 +6,17 @@ export const getBlitzDependencyVersion = async (
|
||||
cliVersion: string,
|
||||
): Promise<Fallbackable<string>> => {
|
||||
try {
|
||||
const {latest, canary} = await fetchDistTags("blitz")
|
||||
// TODO: Need to update this to handle alpha, beta and major
|
||||
const {alpha} = await fetchDistTags("blitz")
|
||||
|
||||
if (cliVersion.includes("canary")) {
|
||||
return {value: canary, isFallback: false}
|
||||
if (alpha) {
|
||||
return {value: alpha}
|
||||
}
|
||||
|
||||
return {value: latest, isFallback: false}
|
||||
logFailedVersionFetch("blitz")
|
||||
return {value: ""}
|
||||
} catch (error) {
|
||||
const fallback = "latest"
|
||||
logFailedVersionFetch("blitz", fallback)
|
||||
return {value: fallback, isFallback: true}
|
||||
logFailedVersionFetch("blitz")
|
||||
return {value: ""}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@ import chalk from "chalk"
|
||||
import {Fallbackable} from "./fallbackable"
|
||||
import {fetchAllVersions, fetchLatestDistVersion} from "./npm-fetch"
|
||||
|
||||
export const logFailedVersionFetch = (dependency: string, fallback: string) => {
|
||||
// log.clearLine()
|
||||
export const logFailedVersionFetch = (dependency: string, fallback?: string) => {
|
||||
console.warn(
|
||||
`Failed to fetch latest version of '${chalk.bold(dependency)}', falling back to '${chalk.bold(
|
||||
fallback,
|
||||
)}'.`,
|
||||
`Failed to fetch latest version of '${chalk.bold(dependency)}'`,
|
||||
fallback ? `Falling back to '${chalk.bold(fallback)}'` : "",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export const fetchAllVersions = async (dependency: string) => {
|
||||
return Object.keys(res.versions)
|
||||
}
|
||||
|
||||
type NpmDistTagsResponse = {latest: string; canary: string}
|
||||
type NpmDistTagsResponse = {latest: string; canary: string; alpha: string}
|
||||
|
||||
export const fetchDistTags = async (dependency: string) => {
|
||||
const res = await got(`https://registry.npmjs.org/-/package/${dependency}/dist-tags`, {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Form, FORM_ERROR } from "app/core/components/Form"
|
||||
import login from "app/auth/mutations/login"
|
||||
import { Login } from "app/auth/validations"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
type LoginFormProps = {
|
||||
onSuccess?: (user: PromiseReturnType<typeof login>) => void
|
||||
@@ -39,7 +40,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
<LabeledTextField name="email" label="Email" placeholder="Email" />
|
||||
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
|
||||
<div>
|
||||
<Link href="/auth/forgot-password">
|
||||
<Link href={Routes.ForgotPasswordPage()}>
|
||||
<a>Forgot your password?</a>
|
||||
</Link>
|
||||
</div>
|
||||
@@ -47,7 +48,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
|
||||
<div style={{ marginTop: "1rem" }}>
|
||||
Or{" "}
|
||||
<Link href="/auth/signup">
|
||||
<Link href={Routes.SignupPage()}>
|
||||
<a>Sign Up</a>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { useRouter } from "next/router"
|
||||
import Layout from "app/core/layouts/Layout"
|
||||
import { SignupForm } from "app/auth/components/SignupForm"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
const SignupPage = () => {
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<Layout title="Sign Up">
|
||||
<SignupForm onSuccess={() => router.push("/")} />
|
||||
<SignupForm onSuccess={() => router.push(Routes.Home())} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useCurrentUser } from "app/core/hooks/useCurrentUser"
|
||||
import logout from "app/auth/mutations/logout"
|
||||
import logo from "public/logo.png"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import { Routes } from "@blitzjs/next"
|
||||
|
||||
/*
|
||||
* This file is just for a pleasant getting started page for your new app.
|
||||
@@ -37,12 +38,12 @@ const UserInfo = () => {
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Link href="/auth/signup">
|
||||
<Link href={Routes.SignupPage()}>
|
||||
<a className="button small">
|
||||
<strong>Sign Up</strong>
|
||||
</a>
|
||||
</Link>
|
||||
<Link href="/auth/login">
|
||||
<Link href={Routes.LoginPage()}>
|
||||
<a className="button small">
|
||||
<strong>Login</strong>
|
||||
</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"baseUrl": "./",
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
@@ -17,7 +17,7 @@
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": ".tsbuildinfo"
|
||||
"tsBuildInfoFile": ".tsbuildinfo",
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.e2e.ts", "cypress"],
|
||||
"include": ["blitz-env.d.ts", "**/*.ts", "**/*.tsx", "types"]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"baseUrl": "./",
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
"@typescript-eslint/parser": "5.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "2.0.0-alpha.11",
|
||||
"@blitzjs/config": "2.0.0-alpha.19",
|
||||
"@types/react": "17.0.43",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"react": "18.0.0",
|
||||
|
||||
1004
pnpm-lock.yaml
generated
1004
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user