UNPKG

@veecode-platform/safira-cli

Version:

Generate a microservice project from your spec.

23 lines (22 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GenerateFileTemplate = void 0; const tslib_1 = require("tslib"); const file_system_utils_1 = require("../../utils/file-system-utils"); const Mustache = tslib_1.__importStar(require("mustache")); const template_1 = require("../../assets/templates/template"); class GenerateFileTemplate { writeFile(writeFilePath, templatePath, templateFields) { if (!file_system_utils_1.FileSystemUtils.exists(templatePath)) { throw new Error(`Template ${templatePath} not found`); } const destinyFolder = file_system_utils_1.FileSystemUtils.getDirectoryPath(writeFilePath); if (!file_system_utils_1.FileSystemUtils.exists(destinyFolder)) file_system_utils_1.FileSystemUtils.createFolder(destinyFolder); const templateContent = file_system_utils_1.FileSystemUtils.loadFile(templatePath); templateFields["created-at"] = new Date().toISOString(); file_system_utils_1.FileSystemUtils.writeFile(writeFilePath, Mustache.render(templateContent, templateFields)); } } exports.GenerateFileTemplate = GenerateFileTemplate; GenerateFileTemplate.templatesFolder = template_1.Template.getpath();