import * as path from "node:path"; import * as fs from "fs"; import {json} from "node:stream/consumers"; export class DeleteTransaction { static deleteScriptAccount(projectDir: string, componentName: string) { const filename = path.join(projectDir, "script-accounts", componentName + ".json") fs.unlinkSync(filename) console.log("Delete ", filename) } static deleteGamesystem(projectDir: string, componentName: string) { const gamesystemDir = path.join(projectDir, "gamesystems") const gamesystemFile = this.findGamesystemPath(gamesystemDir, componentName) try { if(gamesystemFile != undefined) { console.log("Delete Gamesystem under File: ", gamesystemFile) if(fs.lstatSync(gamesystemFile).isDirectory()) { fs.rmSync(gamesystemFile, {recursive: true, force: true}) } else { fs.unlinkSync(gamesystemFile) } } }catch (e) { console.log(e) } } static findGamesystemPath(gamesystemRootDir: string, searchedFilename: string) { const directoriesToProcess: string[] = []; directoriesToProcess.push(gamesystemRootDir); while(directoriesToProcess.length > 0) { const currentDirectory = directoriesToProcess.shift(); const filesInDirectory = fs.readdirSync(currentDirectory!) for(let i=0; i