UNPKG

create-types-backend

Version:

A CLI tool to quickly setup an Express.js backend in TypeScript, using essential configurations and user's preferences.

35 lines (34 loc) 1.55 kB
import chalk from "chalk"; import { execSync } from "child_process"; export const installDependencies = (answers) => { console.log(chalk.green("📥 Installing dependencies...")); let dependencies = ["express", "dotenv"]; if (answers.useCors) dependencies.push("cors"); if (answers.useMongo) dependencies.push("mongoose"); if (answers.useAuth) dependencies.push("jsonwebtoken", "cookie-parser", "bcrypt"); if (answers.useMulter) dependencies.push("multer"); if (answers.useCloudinary) dependencies.push("cloudinary", "sharp", "streamifier", "uuid"); execSync(`npm install ${dependencies.join(" ")}`, { stdio: "ignore" }); }; export const installDevDependencies = (answers) => { console.log(chalk.green("🛠️ Installing dev dependencies...")); let devDependencies = ["@types/node", "@types/express@4", "typescript", "tsc-alias", "tsx"]; if (answers.useCors) devDependencies.push("@types/cors"); if (answers.useMongo) devDependencies.push("@types/mongoose"); if (answers.useAuth) devDependencies.push("@types/jsonwebtoken", "@types/cookie-parser", "@types/bcrypt"); if (answers.useMulter) devDependencies.push("@types/multer"); if (answers.useCloudinary) devDependencies.push("@types/streamifier", "@types/uuid"); if (answers.useESLint) devDependencies.push("eslint", "@eslint/js", "typescript-eslint", "globals"); execSync(`npm install -D ${devDependencies.join(" ")}`, { stdio: "ignore" }); };