diff --git a/.changeset/moody-bobcats-shake.md b/.changeset/moody-bobcats-shake.md new file mode 100644 index 0000000..5616f1a --- /dev/null +++ b/.changeset/moody-bobcats-shake.md @@ -0,0 +1,5 @@ +--- +"create-jd-app": patch +--- + +More Detailed Readme.md For Starter Projects diff --git a/src/helpers/solid.ts b/src/helpers/solid.ts index d025835..37a7370 100644 --- a/src/helpers/solid.ts +++ b/src/helpers/solid.ts @@ -1,14 +1,15 @@ import { execFiles } from "~utils/files"; -import type { ICtx, IFile } from "~types"; +import type { ICtx, IEnv, IFile } from "~types"; import getIndexLocation from "./utils/getIndexLocation"; -const helperFunc = async (ctx: ICtx) => { +const helperFunc = async (ctx: ICtx, env: IEnv[]) => { const indexLocation = getIndexLocation(ctx); const files: IFile[] = [ { path: `${__dirname}/utils/getReadMe`, type: "exec", to: `${ctx.userDir}/README.MD`, + pass: env, }, ]; if (indexLocation) { diff --git a/src/helpers/utils/getReadMe.ts b/src/helpers/utils/getReadMe.ts index c538dea..9a48886 100644 --- a/src/helpers/utils/getReadMe.ts +++ b/src/helpers/utils/getReadMe.ts @@ -1,17 +1,43 @@ -import type { IUtil } from "~types"; +import type { IEnv, IUtil } from "~types"; -const getReadMe: IUtil = (ctx) => { - const usePrisma = ctx.installers.includes("Prisma"); - return `# Create JD App +const getReadMe: IUtil = (ctx, passed = []) => { + const envContent = `### Enviroment Variables -This project was created using [Create JD App](https://github.com/OrJDev/create-jd-app) +${passed + .filter((env) => !env.ignore || env.key === "ENABLE_VC_BUILD") + .map((env) => `- \`${env.key}\`=${env.defaulValue ?? ""}`) + .join("\n")} + `; + const runCmd = ctx.pkgManager === "pnpm" ? "" : " run"; + return `This project was created using [Create JD App](https://github.com/OrJDev/create-jd-app) -${ - ctx.vercel - ? `## Deploying To Vercel +## Start Dev Server + +\`\`\`bash +${ctx.pkgManager}${runCmd} dev +\`\`\` + +This will start a dev server on port \`3000\` and will watch for changes. + +## Testing Production Build + +### Build + +\`\`\`bash +${ctx.pkgManager}${runCmd} build +\`\`\` + +### Start + +\`\`\`bash +${ctx.pkgManager}${runCmd} start +\`\`\` + +This will start a production server on port \`3000\`. ${ ctx.vercel === "Cli" - ? ` + ? `\n## Deploying To Vercel + ### Building \`\`\`bash @@ -23,18 +49,10 @@ ${ \`\`\`bash vercel deploy --prod --prebuilt \`\`\`` - : `### You Are Done -Create a github repo and push your code to it, then deploy it to vercel (:` -} - -### Enviroment Variables - -- \`ENABLE_VC_BUILD\`=\`1\` .${ - usePrisma ? "\n- `DATABASE_URL`=`your database url` ." : "" - } -` : "" } +${envContent} +[Sponsor Create JD App](https://github.com/sponsors/OrJDev) `; }; diff --git a/src/types.ts b/src/types.ts index f686d0c..81228f1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -39,6 +39,8 @@ export type IFile = { type?: "copy" | "exec" | "delete" | "write" | "append"; path?: string; sep?: boolean; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + pass?: any; }; export type IEnv = { @@ -49,7 +51,7 @@ export type IEnv = { kind: "server" | "client"; }; -export type IUtil = (ctx: ICtx) => string; +export type IUtil = (ctx: ICtx, passed?: T) => string; export type TInstallers = | "AuthJS" diff --git a/src/utils/files.ts b/src/utils/files.ts index 8eb7c80..d094ab5 100644 --- a/src/utils/files.ts +++ b/src/utils/files.ts @@ -25,7 +25,7 @@ async function execFile(file: IFile, ctx: ICtx) { return; } const method = await import(file.path); - await fs.outputFile(file.to, method.default(ctx)); + await fs.outputFile(file.to, method.default(ctx, file.pass)); } else if (file.type === "delete") { await fs.remove(file.to); } else if (file.type === "write") { diff --git a/src/utils/project.ts b/src/utils/project.ts index 6500ec7..7a8c3ab 100644 --- a/src/utils/project.ts +++ b/src/utils/project.ts @@ -135,7 +135,7 @@ export async function modifyProject( const spinner = ora("Modifying project").start(); try { await Promise.all([ - solidHelper(ctx), + solidHelper(ctx, env), updateEnv(ctx.userDir, env), solidUpdateJSON(ctx, scripts, pkgs), modifyConfigIfNeeded(ctx), diff --git a/src/vercel.ts b/src/vercel.ts index bc93c1b..50f511e 100644 --- a/src/vercel.ts +++ b/src/vercel.ts @@ -9,6 +9,7 @@ export const vercelEnv: IEnv[] = [ { key: "ENABLE_VC_BUILD", ignore: true, + defaulValue: "1", type: 'string().default("1").transform((v) => parseInt(v))', kind: "server", }, diff --git a/template/base/README.MD b/template/base/README.MD index 0d8ff27..65f86ef 100644 --- a/template/base/README.MD +++ b/template/base/README.MD @@ -1,43 +1,27 @@ -# Create JD App - This project was created using [Create JD App](https://github.com/OrJDev/create-jd-app) -# Deploying - -### Vercel Adapter (or any other adapter) - -#### Installing +## Start Dev Server ```bash -npm install -D solid-start-vercel@latest +pnpm dev ``` -#### Adding to vite config - -```ts -import solid from "solid-start/vite"; -import dotenv from "dotenv"; -import { defineConfig } from "vite"; -// @ts-ignore -import vercel from "solid-start-vercel"; - -export default defineConfig(() => { - dotenv.config(); - return { - plugins: [solid({ ssr: false, adapter: vercel({ edge: false }) })], - }; -}); -``` +This will start a dev server on port `3000` and will watch for changes. -### Enviroment Variables +## Testing Production Build -- `ENABLE_VC_BUILD` set to `1` . -- If you are using prisma: `DATABASE_URL` set to your `database url`. +### Build -### In Case You Are Using Prisma +```bash +pnpm build +``` + +### Start -i created a script that will copy prisma schema to the vercel output folder, if you are using different service please modify the `postbuild` script in `package.json` and make sure you copy the scheme to the output folder. +```bash +pnpm start +``` -### You Are Done +This will start a production server on port `3000`. -Create a github repo and push your code to it, then deploy it to vercel (: +[Sponsor Create JD App](https://github.com/sponsors/OrJDev)