diff --git a/README.MD b/README.MD index c4a9370..ae04e88 100644 --- a/README.MD +++ b/README.MD @@ -13,6 +13,7 @@ npm create jd-app@latest - [Solid Start](https://github.com/solidjs/solid-start) - [TypeScript](https://github.com/microsoft/TypeScript) - [Zod](https://github.com/colinhacks/zod) +- [Solid EsLint](https://github.com/solidjs-community/eslint-plugin-solid) ## Addons @@ -22,7 +23,6 @@ All addons are optional, you may select some, you may select all and you may sel - [tRPC](https://github.com/trpc/trpc) - [TailwindCSS](https://github.com/tailwindlabs/tailwindcss) - [UnoCSS](https://github.com/unocss/unocss) -- [SolidAuth](https://github.com/orjdev/solid-auth) - [Next Auth](https://github.com/orjdev/auth-solid) - [Upstash Ratelimit](https://github.com/upstash/ratelimit) diff --git a/package.json b/package.json index 10e4753..257405a 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "create-jd-app", - "version": "1.0.113", + "version": "1.0.115", "main": "dist/index.js", "scripts": { "test": "ts-node -r tsconfig-paths/register src", "build": "rm -rf dist && tsc -p . && tsc-alias -p tsconfig.json", "postbuild": "ts-node -r tsconfig-paths/register src/scripts/copyFiles", "patch": "npm version patch --no-git-tag-version", - "cp": "ts-node -r tsconfig-paths/register src/scripts/copyFiles", "dev": "npm link && cd dist && npm link create-jd-app" }, "bin": { diff --git a/src/helpers/installer.ts b/src/helpers/installer.ts index f7ece06..94fa29d 100644 --- a/src/helpers/installer.ts +++ b/src/helpers/installer.ts @@ -8,6 +8,7 @@ import { formatError } from "~utils/helpers"; import { vercelPackages, vercelEnv } from "~vercel"; import chalk from "chalk"; import { IExpectedPackages } from "./packages"; +import { TInstallers } from "~types"; export default async ( ctx: ICtx @@ -93,7 +94,7 @@ export async function getCtxWithInstallers( curr: string[] ): Promise { let installers: string[] = []; - let pkgs: string[] = []; + let pkgs: TInstallers[] = []; const skip = curr.includes("skip"); try { installers = await fs.readdir(path.join(__dirname, "../installers")); @@ -113,10 +114,7 @@ export async function getCtxWithInstallers( let optInstallers = installers.filter( (pkg) => !validInstallers.includes(pkg) ); - const opts = [ - ["TailwindCSS", "UnoCSS"], - ["SolidAuth", "NextAuth"], - ]; + const opts = [["TailwindCSS", "UnoCSS"]]; for (const opt of opts) { for (const op of opt) { if (validInstallers.includes(op)) { @@ -125,7 +123,7 @@ export async function getCtxWithInstallers( } } const newPkgs = ( - await inquirer.prompt<{ pkgs: string[] }>({ + await inquirer.prompt<{ pkgs: TInstallers[] }>({ name: "pkgs", type: "checkbox", message: "What should we use for this app?", @@ -142,9 +140,9 @@ export async function getCtxWithInstallers( }, }) ).pkgs; - pkgs = [...validInstallers, ...newPkgs]; + pkgs = [...validInstallers, ...newPkgs] as TInstallers[]; } else { - pkgs = validInstallers; + pkgs = validInstallers as TInstallers[]; } } if (pkgs.includes("Prisma") && !ctx.vercel) { diff --git a/src/helpers/packages.ts b/src/helpers/packages.ts index 1880c62..58ae351 100644 --- a/src/helpers/packages.ts +++ b/src/helpers/packages.ts @@ -20,9 +20,6 @@ const packages = { "@trpc/server": "^10.1.0", "solid-start-trpc": "^0.0.16", "solid-trpc": "^0.0.11-rc.2", - // solid auth - "@solid-auth/core": "^0.0.1", - "@solid-auth/socials": "^0.0.2", // next auth "@solid-auth/next": "^0.0.19", "@auth/core": "^0.1.4", diff --git a/src/helpers/utils/getIndexPage.ts b/src/helpers/utils/getIndexPage.ts index 0c39262..7db43d3 100644 --- a/src/helpers/utils/getIndexPage.ts +++ b/src/helpers/utils/getIndexPage.ts @@ -7,10 +7,8 @@ const getIndexPage: IUtil = (ctx) => { const useStyles = useUno || uswTW; const useTRPC = ctx.installers.includes("tRPC"); const useNextAuth = ctx.installers.includes("NextAuth"); - const useSolidAuth = ctx.installers.includes("SolidAuth"); - const useAuth = useNextAuth || useSolidAuth; const shouldUsePrisma = - ctx.installers.includes("Prisma") && !useTRPC && !useAuth; + ctx.installers.includes("Prisma") && !useTRPC && !useNextAuth; const withStyles = getStyle( useStyles, `font-bold text-2xl ${useUno ? "text-gray" : "text-gray-500"}` @@ -22,28 +20,22 @@ const getIndexPage: IUtil = (ctx) => { } mx-3 my-3 rounded-lg w-56 p-2.5 text-white font-bold flex items-center justify-center` ); - const loginKey = useSolidAuth ? "discord" : "github"; - const innerRes = getRes(useNextAuth, useSolidAuth, shouldUsePrisma, useTRPC); + const innerRes = getRes(useNextAuth, shouldUsePrisma, useTRPC); const innerContent = getContent( withStyles, - useSolidAuth, useNextAuth, shouldUsePrisma, - loginKey, useTRPC, withButtonStyles ); return `import { type VoidComponent${ - useTRPC || shouldUsePrisma || useAuth ? ", Switch, Match" : "" + useTRPC || shouldUsePrisma || useNextAuth ? ", Switch, Match" : "" }${shouldUsePrisma ? ", createResource" : ""} } from "solid-js"; -import { Title${useAuth ? ", useRouteData" : ""} } from "solid-start";${ +import { Title${useNextAuth ? ", useRouteData" : ""} } from "solid-start";${ useTRPC ? '\nimport { trpc } from "~/utils/trpc";' : "" }${ - useAuth ? `\nimport { createServerData$ } from "solid-start/server";` : "" - }${ - useSolidAuth - ? `\nimport { authenticator } from "~/server/auth"; -import { authClient } from "~/utils/auth";` + useNextAuth + ? `\nimport { createServerData$ } from "solid-start/server";` : "" }${ useNextAuth @@ -51,14 +43,10 @@ import { authClient } from "~/utils/auth";` : "" } ${ - useAuth + useNextAuth ? `\nexport const routeData = () => { return createServerData$(async (_, { request }) => { - return await ${ - useSolidAuth - ? "authenticator.isAuthenticated(request)" - : "getSession(request, authOpts)" - }; + return await getSession(request, authOpts); }); }; ` @@ -83,22 +71,19 @@ export default getIndexPage; const getRes = ( useNextAuth: boolean, - useSolidAuth: boolean, shouldUsePrisma: boolean, useTRPC: boolean ) => { - if ((useNextAuth || useSolidAuth) && useTRPC) { - return `\n const ${ - useSolidAuth ? "user" : "session" - } = useRouteData(); + if (useNextAuth && useTRPC) { + return `\n const session = useRouteData(); const res = trpc.secret.useQuery(undefined, { get enabled() { - return ${useSolidAuth ? "!!user()" : "!!session()?.user"}; + return !!session()?.user; }, }); `; } - if (useNextAuth || useSolidAuth) { + if (useNextAuth) { return `\n const res = useRouteData();\n`; } return shouldUsePrisma @@ -112,16 +97,12 @@ const getRes = ( const getContent = ( withStyles: string, - useSolidAuth: boolean, useNextAuth: boolean, shouldUsePrisma: boolean, - loginKey: string, useTRPC: boolean, withButtonStyles: string ) => { - const useAuth = useNextAuth || useSolidAuth; - const key = useSolidAuth ? "user" : "session"; - if (useAuth && !useTRPC) { + if (useNextAuth && !useTRPC) { return ` Loading... @@ -136,32 +117,23 @@ const getContent = ( ${ - useSolidAuth - ? `authClient.login("${loginKey}", { - successRedirect: "/", - failureRedirect: "/", - })` - : `signIn("${loginKey}")` - }}${ - withButtonStyles.length ? `\n ${withButtonStyles}` : "" - } + onClick={() => signIn("github")}${ + withButtonStyles.length + ? `\n ${withButtonStyles}` + : "" + } > - Login with ${loginKey} + Login } > @@ -179,50 +151,41 @@ const getContent = ( withStyles.length ? "\n " : "" }> ${ - useAuth && useTRPC && withStyles.length ? "\n" : "" + useNextAuth && useTRPC && withStyles.length ? "\n" : "" }${ - useAuth && useTRPC + useNextAuth && useTRPC ? ` {res.isFetching ? "Loading" : "Not Logged In"}` : "Loading..." - }${useAuth && useTRPC ? "\n " : ""} + }${useNextAuth && useTRPC ? "\n " : ""} ${ - useAuth && useTRPC + useNextAuth && useTRPC ? `\n ${ - useSolidAuth - ? `authClient.login("${loginKey}", { - successRedirect: "/", - failureRedirect: "/", - })}` - : `signIn("${loginKey}")}` - }${ + onClick={() => signIn("github")} + ${ withButtonStyles.length ? `\n ${withButtonStyles}` : "" } > - Login with ${loginKey} + Login } > - -

Loading ${key}

+ +

Loading session

- +