Skip to content

Commit

Permalink
chore: update next to 5.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Aug 2, 2022
1 parent 6905215 commit 3fefb0f
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 8 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [5.4.0](https://github.com/t3-oss/create-t3-app/compare/v5.3.0...v5.4.0) (2022-08-02)

### Features

- add deployment strategy to generated README ([#258](https://github.com/t3-oss/create-t3-app/issues/258)) ([c7d4dce](https://github.com/t3-oss/create-t3-app/commit/c7d4dce182b1c306dc2a41d42483994c336843f4))
- set appName to directory on 'npx create-t3-app .' ([#273](https://github.com/t3-oss/create-t3-app/issues/273)) ([2179f2d](https://github.com/t3-oss/create-t3-app/commit/2179f2d38f74de0e3fda5661f5125d049eb4d238))

### Bug Fixes

- height on small screens ([#256](https://github.com/t3-oss/create-t3-app/issues/256)) ([fe86915](https://github.com/t3-oss/create-t3-app/commit/fe86915ced72dc979e5fe68bd56b038d9c714928))
- missing next-auth types ([#255](https://github.com/t3-oss/create-t3-app/issues/255)) ([ed42629](https://github.com/t3-oss/create-t3-app/commit/ed42629be5fb9be72abd40bbe784f2bda99eec99)), closes [#254](https://github.com/t3-oss/create-t3-app/issues/254)
- **prisma:** make db changes for next-auth on mysql obvious ([#275](https://github.com/t3-oss/create-t3-app/issues/275)) ([e9507c8](https://github.com/t3-oss/create-t3-app/commit/e9507c887e135f3e44357c618689f5cdb2f13c43))

## [5.3.0](https://github.com/t3-oss/create-t3-app/compare/v5.2.1...v5.3.0) (2022-07-25)

### Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-t3-app",
"version": "5.3.0-next.1",
"version": "5.4.0-next.1",
"description": "Create web application with the t3 stack",
"author": "Shoubhit Dash <[email protected]>",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion src/installers/next-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => {
);

const nextAuthDefinitionSrc = path.join(nextAuthAssetDir, "next-auth.d.ts");
const nextAuthDefinitionDest = path.join(projectDir, "next-auth.d.ts");
const nextAuthDefinitionDest = path.join(
projectDir,
"src/types/next-auth.d.ts",
);

fs.copySync(apiHandlerSrc, apiHandlerDest);
fs.copySync(restrictedApiSrc, restrictedApiDest);
Expand Down
6 changes: 6 additions & 0 deletions src/utils/parseNameAndPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Parses the appName and its path from the user input.
* Returns an array of [appName, path] where appName is the name put in the package.json and
* path is the path to the directory where the app will be created.
* If the appName is '.', the name of the directory will be used instead.
* Handles the case where the input includes a scoped package name
* in which case that is being parsed as the name, but not included as the path
* e.g. dir/@mono/app => ["@mono/app", "dir/app"]
Expand All @@ -12,6 +13,11 @@ export const parseNameAndPath = (input: string) => {

let appName = paths[paths.length - 1];

// If the user ran `npx create-t3-app .` or similar, the appName should be the current directory
if (appName === ".") {
appName = process.cwd().split("/").pop();
}

// If the first part is a @, it's a scoped package
const indexOfDelimiter = paths.findIndex((p) => p.startsWith("@"));
if (paths.findIndex((p) => p.startsWith("@")) !== -1) {
Expand Down
10 changes: 7 additions & 3 deletions template/addons/prisma/auth-schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ generator client {

datasource db {
provider = "sqlite"
// NOTE: When using postgresql, mysql or sqlserver, uncomment the @db.text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

Expand All @@ -21,12 +25,12 @@ model Account {
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
refresh_token String? // @db.text
access_token String? // @db.text
expires_at Int?
token_type String?
scope String?
id_token String?
id_token String? // @db.text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Expand Down
128 changes: 128 additions & 0 deletions template/base/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,131 @@
# Create T3 App

This is an app bootstrapped according to the [init.tips](https://init.tips) stack, also known as the T3-Stack.

## Why are there `.js` files in here?

As per [T3-Axiom #3](https://github.com/t3-oss/create-t3-app/tree/next#3-typesafety-isnt-optional), we believe take typesafety as a first class citizen. Unfortunately, not all frameworks and plugins support TypeScript which means some of the configuration files have to be `.js` files.

We try to emphasize that these files are javascript for a reason, by explicitly declaring its type (`cjs` or `mjs`) depending on what's supported by the library it is used by. Also, all the `js` files in this project are still typechecked using a `@ts-check` comment at the top.

## What's next? How do I make an app with this?

We try to keep this project as simple as possible, so you can start with the most basic configuration and then move on to more advanced configuration.

If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.

- [Next-Auth.js](https://next-auth.js.org)
- [Prisma](https://prisma.io)
- [TailwindCSS](https://tailwindcss.com)
- [tRPC](https://trpc.io) (using @next version? [see v10 docs here](https://alpha.trpc.io))

## How do I deploy this?

### Vercel

We recommend deploying to [Vercel](https://vercel.com/?utm_source=t3-oss&utm_campaign=oss). It makes it super easy to deploy NextJs apps.

- Push your code to a GitHub repository.
- Go to [Vercel](https://vercel.com/?utm_source=t3-oss&utm_campaign=oss) and sign up with GitHub.
- Create a Project and import the repository you pushed your code to.
- Add your environment variables.
- Click **Deploy**
- Now whenever you push a change to your repository, Vercel will automatically redeploy your website!

### Docker

You can also dockerize this stack and deploy a container.

1. In your [next.config.mjs](./next.config.mjs), add the `output: "standalone"` option to your config.
2. Create a `.dockerignore` file with the following contents:
<details>
<summary>.dockerignore</summary>

```
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
```

</details>

3. Create a `Dockerfile` with the following contents:
<details>
<summary>Dockerfile</summary>

```Dockerfile
# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# You only need to copy next.config.js if you are NOT using the default configuration
# COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
```

</details>

4. You can now build an image to deploy yourself, or use a PaaS such as [Railway's](https://railway.app) automated [Dockerfile deployments](https://docs.railway.app/deploy/dockerfiles) to deploy your app.

## Useful resources

Here are some resources that we commonly refer to:

- [Protecting routes with Next-Auth.js](https://next-auth.js.org/configuration/nextjs#unstable_getserversession)
2 changes: 1 addition & 1 deletion template/page-studs/index/with-auth-trpc-tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Home: NextPage = () => {
<meta name="description" content="Generated by create-t3-app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="container flex flex-col items-center justify-center h-screen p-4 mx-auto">
<main className="container flex flex-col items-center justify-center min-h-screen p-4 mx-auto">
<h1 className="text-5xl md:text-[5rem] leading-normal font-extrabold text-gray-700">
Create <span className="text-purple-300">T3</span> App
</h1>
Expand Down
2 changes: 1 addition & 1 deletion template/page-studs/index/with-trpc-tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Home: NextPage = () => {
<meta name="description" content="Generated by create-t3-app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="container flex flex-col items-center justify-center h-screen p-4 mx-auto">
<main className="container flex flex-col items-center justify-center min-h-screen p-4 mx-auto">
<h1 className="text-5xl md:text-[5rem] leading-normal font-extrabold text-gray-700">
Create <span className="text-purple-300">T3</span> App
</h1>
Expand Down
2 changes: 1 addition & 1 deletion template/page-studs/index/with-tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Home: NextPage = () => {
<meta name="description" content="Generated by create-t3-app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="container flex flex-col items-center justify-center h-screen p-4 mx-auto">
<main className="container flex flex-col items-center justify-center min-h-screen p-4 mx-auto">
<h1 className="text-5xl md:text-[5rem] leading-normal font-extrabold text-gray-700">
Create <span className="text-purple-300">T3</span> App
</h1>
Expand Down

0 comments on commit 3fefb0f

Please sign in to comment.