Skip to content

Commit 4596004

Browse files
authored
Merge branch 'next' into iduuck/issue-1000
2 parents a6aa508 + d973f18 commit 4596004

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+286
-192
lines changed

Diff for: .changeset/green-laws-hammer.md

-6
This file was deleted.

Diff for: .eslintrc.cjs

+29-10
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,47 @@ module.exports = {
22
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
33
plugins: ["turbo"],
44
extends: [
5-
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5+
"plugin:@typescript-eslint/recommended",
66
"plugin:prettier/recommended",
77
],
8+
overrides: [
9+
{
10+
extends: [
11+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
12+
],
13+
files: ["*.ts", "*.tsx"],
14+
parserOptions: {
15+
project: "tsconfig.json",
16+
},
17+
rules: {
18+
"@typescript-eslint/require-await": "off",
19+
"@typescript-eslint/restrict-plus-operands": "off",
20+
"@typescript-eslint/restrict-template-expressions": "off",
21+
22+
// These rules are only disabled because we hit a bug in linting.
23+
// See https://github.com/t3-oss/create-t3-app/pull/1036#discussion_r1060505136
24+
// If you still see the bug once TypeScript@5 is used, please let typescript-eslint know!
25+
"@typescript-eslint/no-unsafe-argument": "off",
26+
"@typescript-eslint/no-unsafe-assignment": "off",
27+
"@typescript-eslint/no-unsafe-call": "off",
28+
"@typescript-eslint/no-unsafe-call": "off",
29+
"@typescript-eslint/no-unsafe-member-access": "off",
30+
"@typescript-eslint/no-unsafe-return": "off",
31+
},
32+
},
33+
],
834
parserOptions: {
935
ecmaVersion: "latest", // Allows for the parsing of modern ECMAScript features
1036
sourceType: "module", // Allows for the use of import
1137
project: "./tsconfig.eslint.json", // Allows for the use of rules which require parserServices to be generated
1238
},
1339
rules: {
1440
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
15-
"@typescript-eslint/explicit-function-return-type": "off",
16-
"@typescript-eslint/explicit-module-boundary-types": "off",
1741
"@typescript-eslint/no-explicit-any": "off",
18-
"@typescript-eslint/no-floating-promises": "error",
19-
"prettier/prettier": ["error", { endOfLine: "auto" }],
42+
"@typescript-eslint/no-non-null-assertion": "off",
2043
"@typescript-eslint/no-unused-vars": [
2144
"error",
22-
{
23-
argsIgnorePattern: "^_",
24-
varsIgnorePattern: "^_",
25-
caughtErrorsIgnorePattern: "^_",
26-
},
45+
{ argsIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_" },
2746
],
2847
},
2948
};

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ yarn-error.log*
4040
.nuxt/
4141
tmp/
4242
temp/
43-
.eslintcache
4443
.docusaurus
4544

4645
# MAC

Diff for: .turbo-cookie

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cookie

Diff for: cli/CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 7.1.0
4+
5+
### Minor Changes
6+
7+
- [#1036](https://github.com/t3-oss/create-t3-app/pull/1036) [`c5ca65e`](https://github.com/t3-oss/create-t3-app/commit/c5ca65e03e2a9d1c3c7f6844eb678402b0fa8993) Thanks [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)! - use typescript-eslint's recommended-required-type-checking
8+
9+
## 7.0.2
10+
11+
### Patch Changes
12+
13+
- [#1056](https://github.com/t3-oss/create-t3-app/pull/1056) [`c6704fb`](https://github.com/t3-oss/create-t3-app/commit/c6704fbeef1473e77ad62543770f1804645389a8) Thanks [@prashantrahul141](https://github.com/prashantrahul141)! - fix: update `package.json->name` before installing dependencies.
14+
15+
## 7.0.1
16+
17+
### Patch Changes
18+
19+
- [#1043](https://github.com/t3-oss/create-t3-app/pull/1043) [`6fe7e1e`](https://github.com/t3-oss/create-t3-app/commit/6fe7e1e1025f46ea8fe6cc82bee7a68e96864078) Thanks [@juliusmarminge](https://github.com/juliusmarminge)! - fix(cli): exit with error code when aborting installation
20+
fix(cli): don't log when scaffolding in current directory and it's empty
21+
322
## 7.0.0
423

524
### Major Changes

Diff for: cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-t3-app",
3-
"version": "7.0.0",
3+
"version": "7.1.0",
44
"description": "Create web application with the t3 stack",
55
"license": "MIT",
66
"repository": {
@@ -31,7 +31,7 @@
3131
"dev": "tsup --watch",
3232
"clean": "rm -rf dist .turbo node_modules",
3333
"start": "node dist/index.js",
34-
"lint": "eslint src --cache --cache-strategy content",
34+
"lint": "eslint src --report-unused-disable-directives",
3535
"format": "prettier --write --plugin-search-dir=. **/*.{cjs,mjs,ts,tsx,md,json} --ignore-path ../.gitignore",
3636
"format:check": "prettier --check --plugin-search-dir=. **/*.{cjs,mjs,ts,tsx,md,json} --ignore-path ../.gitignore",
3737
"release": "changeset version",

Diff for: cli/src/cli/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const runCli = async () => {
176176
} catch (err) {
177177
// If the user is not calling create-t3-app from an interactive terminal, inquirer will throw an error with isTTYError = true
178178
// If this happens, we catch the error, tell the user what has happened, and then continue to run the program with a default t3 app
179-
// eslint-disable-next-line -- Otherwise we have to do some fancy namespace extension logic on the Error type which feels overkill for one line
179+
// Otherwise we have to do some fancy namespace extension logic on the Error type which feels overkill for one line
180180
if (err instanceof Error && (err as any).isTTYError) {
181181
logger.warn(
182182
`${CREATE_T3_APP} needs an interactive terminal to provide options`,

Diff for: cli/src/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ const main = async () => {
4545
noInstall,
4646
});
4747

48-
if (!noInstall) {
49-
await installDependencies({ projectDir });
50-
}
51-
52-
logNextSteps({ projectName: appDir, packages: usePackages, noInstall });
53-
5448
// Write name to package.json
5549
const pkgJson = fs.readJSONSync(
5650
path.join(projectDir, "package.json"),
@@ -65,6 +59,12 @@ const main = async () => {
6559
await initializeGit(projectDir);
6660
}
6761

62+
if (!noInstall) {
63+
await installDependencies({ projectDir });
64+
}
65+
66+
logNextSteps({ projectName: appDir, packages: usePackages, noInstall });
67+
6868
process.exit(0);
6969
};
7070

Diff for: cli/src/installers/dependencyVersionMap.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* This maps the necessary packages to a version.
3+
* This improves performance significantly over fetching it from the npm registry.
4+
*/
5+
export const dependencyVersionMap = {
6+
// NextAuth.js
7+
"next-auth": "^4.18.7",
8+
"@next-auth/prisma-adapter": "^1.0.5",
9+
10+
// Prisma
11+
prisma: "^4.8.0",
12+
"@prisma/client": "^4.8.0",
13+
14+
// TailwindCSS
15+
tailwindcss: "^3.2.0",
16+
autoprefixer: "^10.4.7",
17+
postcss: "^8.4.14",
18+
prettier: "^2.8.1",
19+
"prettier-plugin-tailwindcss": "^0.2.1",
20+
"@types/prettier": "^2.7.2",
21+
22+
// tRPC
23+
"@trpc/client": "^10.7.0",
24+
"@trpc/server": "^10.7.0",
25+
"@trpc/react-query": "^10.7.0",
26+
"@trpc/next": "^10.7.0",
27+
"@tanstack/react-query": "^4.20.0",
28+
superjson: "1.9.1",
29+
} as const;
30+
export type AvailableDependencies = keyof typeof dependencyVersionMap;

Diff for: cli/src/installers/index.ts

-31
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,6 @@ export const availablePackages = [
1616
] as const;
1717
export type AvailablePackages = typeof availablePackages[number];
1818

19-
/*
20-
* This maps the necessary packages to a version.
21-
* This improves performance significantly over fetching it from the npm registry.
22-
*/
23-
export const dependencyVersionMap = {
24-
// NextAuth.js
25-
"next-auth": "^4.18.7",
26-
"@next-auth/prisma-adapter": "^1.0.5",
27-
28-
// Prisma
29-
prisma: "^4.8.0",
30-
"@prisma/client": "^4.8.0",
31-
32-
// TailwindCSS
33-
tailwindcss: "^3.2.0",
34-
autoprefixer: "^10.4.7",
35-
postcss: "^8.4.14",
36-
prettier: "^2.8.1",
37-
"prettier-plugin-tailwindcss": "^0.2.1",
38-
"@types/prettier": "^2.7.2",
39-
40-
// tRPC
41-
"@trpc/client": "^10.7.0",
42-
"@trpc/server": "^10.7.0",
43-
"@trpc/react-query": "^10.7.0",
44-
"@trpc/next": "^10.7.0",
45-
"@tanstack/react-query": "^4.20.0",
46-
superjson: "1.9.1",
47-
} as const;
48-
export type AvailableDependencies = keyof typeof dependencyVersionMap;
49-
5019
export interface InstallerOptions {
5120
projectDir: string;
5221
pkgManager: PackageManager;

Diff for: cli/src/installers/nextAuth.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { Installer, AvailableDependencies } from "~/installers/index.js";
1+
import type { Installer } from "~/installers/index.js";
2+
import { AvailableDependencies } from "~/installers/dependencyVersionMap.js";
23
import path from "path";
34
import fs from "fs-extra";
45
import { PKG_ROOT } from "~/consts.js";

Diff for: cli/src/installers/prisma.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const prismaInstaller: Installer = ({ projectDir, packages }) => {
3333
const packageJsonPath = path.join(projectDir, "package.json");
3434

3535
const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson;
36-
packageJsonContent.scripts!.postinstall = "prisma generate"; //eslint-disable-line @typescript-eslint/no-non-null-assertion
36+
packageJsonContent.scripts!.postinstall = "prisma generate";
3737

3838
fs.copySync(schemaSrc, schemaDest);
3939
fs.copySync(clientSrc, clientDest);

Diff for: cli/src/utils/addPackageDependency.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type PackageJson } from "type-fest";
44
import {
55
dependencyVersionMap,
66
AvailableDependencies,
7-
} from "~/installers/index.js";
7+
} from "~/installers/dependencyVersionMap.js";
88
import sortPackageJson from "sort-package-json";
99

1010
export const addPackageDependency = (opts: {
@@ -22,10 +22,8 @@ export const addPackageDependency = (opts: {
2222
const version = dependencyVersionMap[pkgName];
2323

2424
if (devMode) {
25-
//eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2625
pkgJson.devDependencies![pkgName] = version;
2726
} else {
28-
//eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2927
pkgJson.dependencies![pkgName] = version;
3028
}
3129
});

Diff for: cli/src/utils/renderVersionWarning.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export const renderVersionWarning = (npmVersion: string) => {
3737
* https://github.com/facebook/create-react-app/blob/main/packages/create-react-app/LICENSE
3838
*/
3939
import https from "https";
40+
41+
type DistTagsBody = {
42+
latest: string;
43+
};
44+
4045
function checkForLatestVersion(): Promise<string> {
4146
return new Promise((resolve, reject) => {
4247
https
@@ -47,7 +52,7 @@ function checkForLatestVersion(): Promise<string> {
4752
let body = "";
4853
res.on("data", (data) => (body += data));
4954
res.on("end", () => {
50-
resolve(JSON.parse(body).latest);
55+
resolve((JSON.parse(body) as DistTagsBody).latest);
5156
});
5257
} else {
5358
reject();

Diff for: cli/template/base/.eslintrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
{
2+
"overrides": [
3+
{
4+
"extends": [
5+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
6+
],
7+
"files": ["*.ts", "*.tsx"],
8+
"parserOptions": {
9+
"project": "tsconfig.json"
10+
}
11+
}
12+
],
213
"parser": "@typescript-eslint/parser",
314
"parserOptions": {
415
"project": "./tsconfig.json"

Diff for: cli/template/extras/src/pages/api/trpc/[trpc].ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export default createNextApiHandler({
1111
onError:
1212
env.NODE_ENV === "development"
1313
? ({ path, error }) => {
14-
console.error(`❌ tRPC failed on ${path}: ${error}`);
14+
console.error(
15+
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`,
16+
);
1517
}
1618
: undefined,
1719
});

Diff for: cli/template/extras/src/pages/index/with-auth-trpc-tw.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const AuthShowcase: React.FC = () => {
7474
</p>
7575
<button
7676
className="rounded-full bg-white/10 px-10 py-3 font-semibold text-white no-underline transition hover:bg-white/20"
77-
onClick={sessionData ? () => signOut() : () => signIn()}
77+
onClick={sessionData ? () => void signOut() : () => void signIn()}
7878
>
7979
{sessionData ? "Sign out" : "Sign in"}
8080
</button>

Diff for: cli/template/extras/src/pages/index/with-auth-trpc.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const AuthShowcase: React.FC = () => {
7575
</p>
7676
<button
7777
className={styles.loginButton}
78-
onClick={sessionData ? () => signOut() : () => signIn()}
78+
onClick={sessionData ? () => void signOut() : () => void signIn()}
7979
>
8080
{sessionData ? "Sign out" : "Sign in"}
8181
</button>

Diff for: cli/template/extras/src/server/api/trpc/base.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ type CreateContextOptions = Record<string, never>;
3232
* - trpc's `createSSGHelpers` where we don't have req/res
3333
* @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
3434
*/
35-
const createInnerTRPCContext = async (_opts: CreateContextOptions) => {
35+
const createInnerTRPCContext = (_opts: CreateContextOptions) => {
3636
return {};
3737
};
3838

3939
/**
4040
* This is the actual context you'll use in your router. It will be used to
4141
* process every request that goes through your tRPC endpoint
42-
* @link https://trpc.io/docs/context
42+
* @see https://trpc.io/docs/context
4343
*/
44-
export const createTRPCContext = async (_opts: CreateNextContextOptions) => {
45-
return await createInnerTRPCContext({});
44+
export const createTRPCContext = (_opts: CreateNextContextOptions) => {
45+
return createInnerTRPCContext({});
4646
};
4747

4848
/**

Diff for: cli/template/extras/src/server/api/trpc/with-auth-prisma.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type CreateContextOptions = {
3535
* - trpc's `createSSGHelpers` where we don't have req/res
3636
* @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
3737
*/
38-
const createInnerTRPCContext = async (opts: CreateContextOptions) => {
38+
const createInnerTRPCContext = (opts: CreateContextOptions) => {
3939
return {
4040
session: opts.session,
4141
prisma,
@@ -53,7 +53,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => {
5353
// Get the session from the server using the unstable_getServerSession wrapper function
5454
const session = await getServerAuthSession({ req, res });
5555

56-
return await createInnerTRPCContext({
56+
return createInnerTRPCContext({
5757
session,
5858
});
5959
};

Diff for: cli/template/extras/src/server/api/trpc/with-auth.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type CreateContextOptions = {
3434
* - trpc's `createSSGHelpers` where we don't have req/res
3535
* @see https://create.t3.gg/en/usage/trpc#-servertrpccontextts
3636
*/
37-
const createInnerTRPCContext = async (opts: CreateContextOptions) => {
37+
const createInnerTRPCContext = (opts: CreateContextOptions) => {
3838
return {
3939
session: opts.session,
4040
};
@@ -51,7 +51,7 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => {
5151
// Get the session from the server using the unstable_getServerSession wrapper function
5252
const session = await getServerAuthSession({ req, res });
5353

54-
return await createInnerTRPCContext({
54+
return createInnerTRPCContext({
5555
session,
5656
});
5757
};

0 commit comments

Comments
 (0)