"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureDir = ensureDir;
exports.dirExists = dirExists;
exports.copyDir = copyDir;
exports.writeJson = writeJson;
exports.readJson = readJson;
exports.writeFile = writeFile;
exports.readFile = readFile;
exports.getTemplateDir = getTemplateDir;
exports.renameEjsToTs = renameEjsToTs;
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
async function ensureDir(dir) {
    await fs_extra_1.default.ensureDir(dir);
}
async function dirExists(dir) {
    return fs_extra_1.default.pathExists(dir);
}
async function copyDir(src, dest) {
    await fs_extra_1.default.copy(src, dest);
}
async function writeJson(filePath, data) {
    await fs_extra_1.default.writeJson(filePath, data, { spaces: 2 });
}
async function readJson(filePath) {
    return fs_extra_1.default.readJson(filePath);
}
async function writeFile(filePath, content) {
    await fs_extra_1.default.writeFile(filePath, content, 'utf-8');
}
async function readFile(filePath) {
    return fs_extra_1.default.readFile(filePath, 'utf-8');
}
function getTemplateDir(templateName) {
    return path_1.default.join(__dirname, '..', 'templates', templateName);
}
function renameEjsToTs(dir) {
    const files = fs_extra_1.default.readdirSync(dir, { withFileTypes: true });
    for (const file of files) {
        const fullPath = path_1.default.join(dir, file.name);
        if (file.isDirectory()) {
            renameEjsToTs(fullPath);
        }
        else if (file.name.endsWith('.ejs')) {
            const newName = file.name.replace('.ejs', '');
            fs_extra_1.default.renameSync(fullPath, path_1.default.join(dir, newName));
        }
    }
}
//# sourceMappingURL=file.js.map