UNPKG

validstart

Version:

ValidStart is a powerful and intuitive command-line interface (CLI) tool meticulously crafted to streamline the project setup process.

52 lines (40 loc) • 1.61 kB
import fs from "fs-extra"; import path from "path"; import chalk from "chalk";; import { execa } from "execa";; interface Options { projectName: string; projectType: string; language: string; framework: string; selectedTools: string[]; } export async function scaffoldFullstackPython(options: Options): Promise<void> { const { projectName, framework } = options; const projectPath = path.resolve(process.cwd(), projectName); console.log(chalk.cyan(`\nšŸ Creating Python fullstack project with ${chalk.bold(framework)}`)); await fs.mkdirp(projectPath); if (framework.includes("Django")) { await execa("django-admin", ["startproject", projectName], { cwd: path.dirname(projectPath) }); await execa("git", ["init"], { cwd: projectPath }); return; } if (framework.includes("FastAPI")) { const backendPath = path.join(projectPath, "backend"); const frontendPath = path.join(projectPath, "frontend"); await fs.mkdirp(backendPath); await fs.mkdirp(frontendPath); await fs.writeFile( path.join(backendPath, "main.py"), `from fastapi import FastAPI\n\napp = FastAPI()\n\n@app.get("/")\ndef root():\n return {"msg": "FastAPI backend running"}\n`, ); await execa("npm", ["create", "vite@latest", "frontend", "--", "--template", "vanilla"], { cwd: projectPath, stdio: "inherit", }); await execa("git", ["init"], { cwd: projectPath }); } console.log( chalk.green(`\nāœ… Python fullstack project '${projectName}' created at ${projectPath}\n`), ); }