barnes-node-ts-express-starter
Version:
A modern Node.js TypeScript Express starter template with essential development tooling
41 lines (32 loc) • 1.06 kB
JavaScript
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import inquirer from 'inquirer';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function main() {
const { targetDir } = await inquirer.prompt([
{
type: 'input',
name: 'targetDir',
message: 'Enter the name of your new backend project folder:',
default: 'my-backend'
}
]);
const cwd = process.cwd();
const targetPath = path.join(cwd, targetDir);
if (await fs.pathExists(targetPath)) {
console.error(`❌ Directory ${targetDir} already exists.`);
process.exit(1);
}
const templateDir = path.join(__dirname, '../template');
try {
await fs.copy(templateDir, targetPath);
console.log(`✅ Project created at ${targetPath}`);
console.log('Run `cd', targetDir, '` then `npm install` and `npm run dev`');
} catch (err) {
console.error('❌ Error copying template:', err);
}
}
main();