Skip to content

Commit

Permalink
More Detailed Readme.md For Starter Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
OrJDev committed Feb 3, 2023
1 parent 7e680d7 commit 03fc0d9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-bobcats-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-jd-app": patch
---

More Detailed Readme.md For Starter Projects
5 changes: 3 additions & 2 deletions src/helpers/solid.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
56 changes: 37 additions & 19 deletions src/helpers/utils/getReadMe.ts
Original file line number Diff line number Diff line change
@@ -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<IEnv[]> = (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
Expand All @@ -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)
`;
};

Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -49,7 +51,7 @@ export type IEnv = {
kind: "server" | "client";
};

export type IUtil = (ctx: ICtx) => string;
export type IUtil<T = undefined> = (ctx: ICtx, passed?: T) => string;

export type TInstallers =
| "AuthJS"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
46 changes: 15 additions & 31 deletions template/base/README.MD
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 03fc0d9

Please sign in to comment.