validstart
Version:
ValidStart is a powerful and intuitive command-line interface (CLI) tool meticulously crafted to streamline the project setup process.
54 lines (53 loc) ⢠2.29 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.scaffoldFullstackTS = scaffoldFullstackTS;
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
;
const execa_1 = require("execa");
;
async function scaffoldFullstackTS(options) {
const { projectName, framework } = options;
const projectPath = path_1.default.resolve(process.cwd(), projectName);
console.log(chalk_1.default.cyan(`\nš Creating TypeScript fullstack project with ${chalk_1.default.bold(framework)}`));
await fs_extra_1.default.mkdirp(projectPath);
switch (framework.toLowerCase()) {
case "next.js":
await (0, execa_1.execa)("npx", ["create-next-app@latest", ".", "--ts", "--app"], {
cwd: projectPath,
stdio: "inherit",
});
break;
case "remix":
await (0, execa_1.execa)("npx", ["create-remix", "."], {
cwd: projectPath,
stdio: "inherit",
env: {
...process.env,
INIT_CWD: projectPath,
},
});
break;
case "trpc":
await scaffoldTRPC(projectPath);
break;
case "blitz.js":
await (0, execa_1.execa)("npx", ["blitz", "new", projectName, "--typescript"], {
stdio: "inherit",
});
return; // Already handles all
}
console.log(chalk_1.default.gray("š§ Initializing git..."));
await (0, execa_1.execa)("git", ["init"], { cwd: projectPath });
console.log(chalk_1.default.green(`\nā
${framework} fullstack project '${projectName}' created at ${projectPath}\n`));
}
async function scaffoldTRPC(projectPath) {
const repo = "https://github.com/trpc/next-prisma-starter.git";
console.log(chalk_1.default.gray("š¦ Cloning tRPC starter..."));
await (0, execa_1.execa)("git", ["clone", repo, "."], { cwd: projectPath });
await fs_extra_1.default.remove(path_1.default.join(projectPath, ".git"));
}