mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
feat(cli): add react router support with alchemy (#542)
This commit is contained in:
@@ -76,11 +76,12 @@ export async function createProject(options: ProjectConfig) {
|
||||
|
||||
await handleExtras(projectDir, options);
|
||||
|
||||
await setupEnvironmentVariables(options);
|
||||
await updatePackageConfigurations(projectDir, options);
|
||||
|
||||
await setupWebDeploy(options);
|
||||
await setupServerDeploy(options);
|
||||
|
||||
await setupEnvironmentVariables(options);
|
||||
await updatePackageConfigurations(projectDir, options);
|
||||
await createReadme(projectDir, options);
|
||||
|
||||
await writeBtsConfig(options);
|
||||
|
||||
@@ -35,6 +35,8 @@ function generateReadmeContent(options: ProjectConfig): string {
|
||||
frontend = ["tanstack-router"],
|
||||
backend = "hono",
|
||||
api = "trpc",
|
||||
webDeploy,
|
||||
serverDeploy,
|
||||
} = options;
|
||||
|
||||
const isConvex = backend === "convex";
|
||||
@@ -103,6 +105,7 @@ Follow the prompts to create a new Convex project and connect it to your applica
|
||||
packageManagerRunCmd,
|
||||
orm,
|
||||
options.dbSetup,
|
||||
options.serverDeploy,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -120,6 +123,8 @@ ${
|
||||
: ""
|
||||
}
|
||||
|
||||
${generateDeploymentCommands(packageManagerRunCmd, webDeploy, serverDeploy)}
|
||||
|
||||
## Project Structure
|
||||
|
||||
\`\`\`
|
||||
@@ -475,6 +480,7 @@ function generateDatabaseSetup(
|
||||
packageManagerRunCmd: string,
|
||||
orm: ORM,
|
||||
dbSetup: DatabaseSetup,
|
||||
serverDeploy?: string,
|
||||
): string {
|
||||
if (database === "none") {
|
||||
return "";
|
||||
@@ -494,7 +500,9 @@ function generateDatabaseSetup(
|
||||
1. Start the local SQLite database:
|
||||
${
|
||||
dbSetup === "d1"
|
||||
? "Local development for a Cloudflare D1 database will already be running as part of the `wrangler dev` command."
|
||||
? serverDeploy === "alchemy"
|
||||
? "D1 local development and migrations are handled automatically by Alchemy during dev and deploy."
|
||||
: "Local development for a Cloudflare D1 database will already be running as part of the `wrangler dev` command."
|
||||
: `\`\`\`bash
|
||||
cd apps/server && ${packageManagerRunCmd} db:local
|
||||
\`\`\`
|
||||
@@ -632,3 +640,51 @@ function generateScriptsList(
|
||||
|
||||
return scripts;
|
||||
}
|
||||
|
||||
function generateDeploymentCommands(
|
||||
packageManagerRunCmd: string,
|
||||
webDeploy?: string,
|
||||
serverDeploy?: string,
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
if (webDeploy === "alchemy" || serverDeploy === "alchemy") {
|
||||
lines.push("## Deployment (Alchemy)");
|
||||
if (webDeploy === "alchemy" && serverDeploy !== "alchemy") {
|
||||
lines.push(
|
||||
`- Web dev: cd apps/web && ${packageManagerRunCmd} dev`,
|
||||
`- Web deploy: cd apps/web && ${packageManagerRunCmd} deploy`,
|
||||
`- Web destroy: cd apps/web && ${packageManagerRunCmd} destroy`,
|
||||
);
|
||||
}
|
||||
if (serverDeploy === "alchemy" && webDeploy !== "alchemy") {
|
||||
lines.push(
|
||||
`- Server dev: cd apps/server && ${packageManagerRunCmd} dev`,
|
||||
`- Server deploy: cd apps/server && ${packageManagerRunCmd} deploy`,
|
||||
`- Server destroy: cd apps/server && ${packageManagerRunCmd} destroy`,
|
||||
);
|
||||
}
|
||||
if (webDeploy === "alchemy" && serverDeploy === "alchemy") {
|
||||
lines.push(
|
||||
`- Dev: ${packageManagerRunCmd} dev`,
|
||||
`- Deploy: ${packageManagerRunCmd} deploy`,
|
||||
`- Destroy: ${packageManagerRunCmd} destroy`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (webDeploy === "wrangler" || serverDeploy === "wrangler") {
|
||||
lines.push("\n## Deployment (Cloudflare Wrangler)");
|
||||
if (webDeploy === "wrangler") {
|
||||
lines.push(`- Web deploy: cd apps/web && ${packageManagerRunCmd} deploy`);
|
||||
}
|
||||
if (serverDeploy === "wrangler") {
|
||||
lines.push(
|
||||
`- Server dev: cd apps/server && ${packageManagerRunCmd} dev`,
|
||||
`- Server deploy: cd apps/server && ${packageManagerRunCmd} deploy`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.length ? `\n${lines.join("\n")}\n` : "";
|
||||
}
|
||||
|
||||
@@ -412,15 +412,15 @@ function getAlchemyDeployInstructions(
|
||||
|
||||
if (webDeploy === "alchemy" && serverDeploy !== "alchemy") {
|
||||
instructions.push(
|
||||
`${pc.bold("Deploy web with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/web && ${runCmd} alchemy:dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/web && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/web && ${runCmd} destroy`}`,
|
||||
`${pc.bold("Deploy web with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/web && ${runCmd} dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/web && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/web && ${runCmd} destroy`}`,
|
||||
);
|
||||
} else if (serverDeploy === "alchemy" && webDeploy !== "alchemy") {
|
||||
instructions.push(
|
||||
`${pc.bold("Deploy server with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/server && ${runCmd} alchemy:dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/server && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/server && ${runCmd} destroy`}`,
|
||||
`${pc.bold("Deploy server with Alchemy:")}\n${pc.cyan("•")} Dev: ${`cd apps/server && ${runCmd} dev`}\n${pc.cyan("•")} Deploy: ${`cd apps/server && ${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`cd apps/server && ${runCmd} destroy`}`,
|
||||
);
|
||||
} else if (webDeploy === "alchemy" && serverDeploy === "alchemy") {
|
||||
instructions.push(
|
||||
`${pc.bold("Deploy with Alchemy:")}\n${pc.cyan("•")} Dev: ${`${runCmd} alchemy:dev`}\n${pc.cyan("•")} Deploy: ${`${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`${runCmd} destroy`}`,
|
||||
`${pc.bold("Deploy with Alchemy:")}\n${pc.cyan("•")} Dev: ${`${runCmd} dev`}\n${pc.cyan("•")} Deploy: ${`${runCmd} deploy`}\n${pc.cyan("•")} Destroy: ${`${runCmd} destroy`}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -835,12 +835,6 @@ export async function setupDeploymentTemplates(
|
||||
serverAppDir,
|
||||
context,
|
||||
);
|
||||
await processAndCopyFiles(
|
||||
"wrangler.jsonc.hbs",
|
||||
alchemyTemplateSrc,
|
||||
serverAppDir,
|
||||
context,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -885,12 +879,6 @@ export async function setupDeploymentTemplates(
|
||||
serverAppDir,
|
||||
context,
|
||||
);
|
||||
await processAndCopyFiles(
|
||||
"wrangler.jsonc.hbs",
|
||||
alchemyTemplateSrc,
|
||||
serverAppDir,
|
||||
context,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user