Skip to content

Commit

Permalink
feat: remove next-auth checks for node 18 and next 13 (#673)
Browse files Browse the repository at this point in the history
* remove next-auth checks for node 18 and next 13

* require next-auth ^4.16

* chore: add changeset

* fix next-auth version

Co-authored-by: Julius Marminge <julius0216@outlook.com>
  • Loading branch information
c-ehrlich and juliusmarminge committed Nov 4, 2022
1 parent 7eb5e87 commit 44a107b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-crabs-sing.md
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

remove node 18 and next 13 checks
36 changes: 2 additions & 34 deletions cli/src/helpers/installDependencies.ts
@@ -1,51 +1,19 @@
import chalk from "chalk";
import { execa } from "execa";
import ora from "ora";
import { PkgInstallerMap } from "~/installers/index.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
import { logger } from "~/utils/logger.js";

type Options = {
projectDir: string;
packages: PkgInstallerMap;
};

export const installDependencies = async ({
projectDir,
packages,
}: Options) => {
export const installDependencies = async ({ projectDir }: Options) => {
logger.info("Installing dependencies...");
const pkgManager = getUserPkgManager();
const spinner = ora(`Running ${pkgManager} install...\n`).start();
let flags: string[] = [];

// FIXME: temp fix for NextAuth.js with node 18/19
// see: https://github.com/nextauthjs/next-auth/issues/4575
if (
process.versions.node.startsWith("18") ||
process.versions.node.startsWith("19")
) {
flags = [
...flags,
...(pkgManager === "yarn"
? ["--ignore-engines", "true"]
: ["--engine-strict", "false"]),
];
}

// FIXME: temp fix for NextAuth.js with Next.js 13
if (packages.nextAuth.inUse) {
flags = [
...flags,
...(pkgManager === "pnpm"
? ["--strict-peer-dependencies", "false"]
: pkgManager === "npm"
? ["--legacy-peer-deps", "true"]
: []),
];
}

await execa(pkgManager, ["install", ...flags], { cwd: projectDir });
await execa(pkgManager, ["install"], { cwd: projectDir });

spinner.succeed(chalk.green("Successfully installed dependencies!\n"));
};
2 changes: 1 addition & 1 deletion cli/src/index.ts
Expand Up @@ -40,7 +40,7 @@ const main = async () => {
});

if (!noInstall) {
await installDependencies({ projectDir, packages: usePackages });
await installDependencies({ projectDir });
}

if (!noGit) {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/installers/index.ts
Expand Up @@ -22,7 +22,7 @@ export type AvailablePackages = typeof availablePackages[number];
*/
export const dependencyVersionMap = {
// NextAuth.js
"next-auth": "^4.15.0",
"next-auth": "^4.15.1",
"@next-auth/prisma-adapter": "^1.0.4",

// Prisma
Expand Down
9 changes: 0 additions & 9 deletions cli/src/installers/nextAuth.ts
Expand Up @@ -46,15 +46,6 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => {
"src/types/next-auth.d.ts",
);

// FIXME: temp fix for next-auth with node 18
// see: https://github.com/nextauthjs/next-auth/issues/4575
const npmrcSrc = path.join(nextAuthAssetDir, "_npmrc");
const npmrcDest = path.join(projectDir, ".npmrc");
const yarnrcSrc = path.join(nextAuthAssetDir, "_yarnrc");
const yarnrcDest = path.join(projectDir, ".yarnrc");
fs.copySync(npmrcSrc, npmrcDest);
fs.copySync(yarnrcSrc, yarnrcDest);

fs.copySync(apiHandlerSrc, apiHandlerDest);
fs.copySync(getServerAuthSessionSrc, getServerAuthSessionDest);
fs.copySync(restrictedApiSrc, restrictedApiDest);
Expand Down
6 changes: 0 additions & 6 deletions cli/template/addons/next-auth/_npmrc

This file was deleted.

1 change: 0 additions & 1 deletion cli/template/addons/next-auth/_yarnrc

This file was deleted.

1 comment on commit 44a107b

@vercel
Copy link

@vercel vercel bot commented on 44a107b Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.