"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = exports.init = exports.build = void 0; const FileUtils_js_1 = require("./FileUtils.cjs"); const JustMCFResult_js_1 = require("./JustMCFResult.cjs"); const ManageSimplify_js_1 = require("./ManageSimplify.cjs"); async function build(source_path, target_path) { if (source_path === undefined) { throw new JustMCFPathError("error source_path"); } if (target_path === undefined) { throw new JustMCFPathError("error target_path"); } const result = new JustMCFResult_js_1.JustMCFResult(); const fileUtils = new FileUtils_js_1.FileUtils(result, source_path, target_path); const [hasPackMcmeta, _] = await fileUtils.checkPackMcmeta(); if (!hasPackMcmeta) { throw new JustMCFPathError("there was not minecraft data pack in source path, you need to create pack.mcmeta firstly"); } const hasMcfMcmeta = await fileUtils.checkMcfMcmeta(); if (!hasMcfMcmeta) { throw new JustMCFPathError("there was not Just MCF project in source path, you need to initialize firstly"); } const codesObj = await fileUtils.readAllMcf(); const err = (0, ManageSimplify_js_1.build)(codesObj.map(obj => obj.code), result); if (err !== undefined) throw new Error(err.text); if (!source_path.includes(target_path)) await fileUtils.copyAllDataPack(); await fileUtils.createFunctionTag(); await fileUtils.createMcfunction(); await fileUtils.createMcfMcmeta(); } exports.build = build; async function init(source_path) { const option = (0, JustMCFResult_js_1.defaultOption)(); const res = new JustMCFResult_js_1.JustMCFResult(); res.option = option; const file = new FileUtils_js_1.FileUtils(res); await file.createMcfMcmeta(); } exports.init = init; exports.execute = ManageSimplify_js_1.execute; class JustMCFPathError extends Error { constructor(message) { super(message); } }