create-n4-app
Version:
Create Next.js app with the n4 stack
21 lines (20 loc) • 1.11 kB
JavaScript
import { TEMPLATE_PKG } from "../../utils/consts.js";
import fs from "fs-extra";
import path from "path";
import chalk from "chalk";
import { createOAuthSecret, packageInstaller, } from "../../utils/packageInstaller.js";
const CredentialsInstaller = async (packageManger) => {
console.log(chalk.bold("☕ Installing Auth.js..."));
await packageInstaller({
packageManger: packageManger.depn,
installCmd: packageManger.depn === "npm" ? "i" : "add",
packages: ["next-auth@beta"],
});
await createOAuthSecret(packageManger);
const credentialsTemplateDir = path.join(TEMPLATE_PKG, "authjs", "credentials");
await fs.copy(path.join(credentialsTemplateDir, "route"), path.join(process.cwd(), "app"));
await fs.copy(path.join(credentialsTemplateDir, "api-route"), path.join(process.cwd(), "app"));
await fs.copyFile(path.join(credentialsTemplateDir, "middleware.ts"), path.join(process.cwd(), "middleware.ts"));
await fs.copyFile(path.join(credentialsTemplateDir, "auth.ts"), path.join(process.cwd(), "auth.ts"));
};
export default CredentialsInstaller;