import {StorageModel} from "../src/app/game-model/StorageModel"; import * as fs from "fs"; import * as path from "node:path"; export class SaveProject { static saveProject(projectDir: string, storageModels: StorageModel[]) { const directoryPath = 'testModel/' if(!fs.existsSync(directoryPath)) { fs.mkdirSync(directoryPath, {recursive: true}); } storageModels.forEach(storageModel => { const modelDir = path.join(directoryPath, storageModel.storageDir); if(!fs.existsSync(modelDir)) { fs.mkdirSync(modelDir, {recursive: true}); } const filePath = path.join(directoryPath, storageModel.storageDir, storageModel.fileName + ".json"); fs.writeFile(filePath, storageModel.jsonString ,'utf-8', (err) => { if (err) { console.error('Error writing JSON to file:', err); } else { console.log('JSON file saved successfully:', filePath); } }) }) } }