mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
replace commander with brocli, update inquirer and add biome
This commit is contained in:
@@ -1,56 +1,62 @@
|
||||
import { execa } from 'execa';
|
||||
import fs from 'fs-extra';
|
||||
import ora from 'ora';
|
||||
import path from 'path';
|
||||
import { execa } from "execa";
|
||||
import fs from "fs-extra";
|
||||
import ora from "ora";
|
||||
import path from "node:path";
|
||||
|
||||
interface ProjectOptions {
|
||||
projectName: string;
|
||||
typescript: boolean;
|
||||
git: boolean;
|
||||
database: 'libsql' | 'postgres';
|
||||
database: "libsql" | "postgres";
|
||||
auth: boolean;
|
||||
features: string[];
|
||||
}
|
||||
|
||||
export async function createProject(options: ProjectOptions) {
|
||||
const spinner = ora('Creating project directory...').start();
|
||||
const spinner = ora("Creating project directory...").start();
|
||||
const projectDir = path.resolve(process.cwd(), options.projectName);
|
||||
|
||||
try {
|
||||
await fs.ensureDir(projectDir);
|
||||
spinner.succeed();
|
||||
|
||||
spinner.start('Cloning template repository...');
|
||||
await execa('git', ['clone', '--depth', '1', 'https://github.com/AmanVarshney01/Better-T-Stack.git', projectDir]);
|
||||
spinner.start("Cloning template repository...");
|
||||
await execa("git", [
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/AmanVarshney01/Better-T-Stack.git",
|
||||
projectDir,
|
||||
]);
|
||||
spinner.succeed();
|
||||
spinner.start('Removing template .git folder...');
|
||||
await fs.remove(path.join(projectDir, '.git'));
|
||||
spinner.start("Removing template .git folder...");
|
||||
await fs.remove(path.join(projectDir, ".git"));
|
||||
spinner.succeed();
|
||||
|
||||
if (options.git) {
|
||||
spinner.start('Initializing git repository...');
|
||||
await execa('git', ['init'], { cwd: projectDir });
|
||||
spinner.start("Initializing git repository...");
|
||||
await execa("git", ["init"], { cwd: projectDir });
|
||||
spinner.succeed();
|
||||
}
|
||||
|
||||
spinner.start('Installing dependencies...');
|
||||
await execa('bun', ['install'], { cwd: projectDir });
|
||||
spinner.start("Installing dependencies...");
|
||||
await execa("bun", ["install"], { cwd: projectDir });
|
||||
spinner.succeed();
|
||||
|
||||
spinner.start('Setting up database...');
|
||||
if (options.database === 'libsql') {
|
||||
await execa('bun', ['run', 'db:local'], { cwd: projectDir });
|
||||
await execa('bun', ['run', 'db:push'], { cwd: projectDir });
|
||||
spinner.start("Setting up database...");
|
||||
if (options.database === "libsql") {
|
||||
await execa("bun", ["run", "db:local"], { cwd: projectDir });
|
||||
await execa("bun", ["run", "db:push"], { cwd: projectDir });
|
||||
}
|
||||
spinner.succeed();
|
||||
|
||||
console.log('\n✨ Project created successfully!\n');
|
||||
console.log('Next steps:');
|
||||
console.log("\n✨ Project created successfully!\n");
|
||||
console.log("Next steps:");
|
||||
console.log(` cd ${options.projectName}`);
|
||||
console.log(' bun dev');
|
||||
console.log(" bun dev");
|
||||
} catch (error) {
|
||||
spinner.fail('Failed to create project');
|
||||
spinner.fail("Failed to create project");
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user