"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateIpa=void 0;const zip_1=require("./zip"),path=require("path"),os=require("os"),fse=require("fs-extra");async function generateIpa(e,i){let r="";if(e.endsWith(".app")){const a=path.basename(e),p=os.tmpdir();r=path.join(p,"miniapp-unsigned.ipa");const t=path.join(p,"appdir"),n=path.join(t,"Payload");fse.existsSync(t)&&fse.removeSync(t),fse.ensureDirSync(n),fse.copySync(e,path.join(n,a)),null==i||i.progress("pack the ipa..."),fse.existsSync(r)&&fse.removeSync(r);try{await(0,zip_1.archiveZip)(t,r)}catch(e){throw new Error("generateIpa failed archiveZip file")}}else{if(!e.endsWith(".ipa"))throw new Error("invalid ipa/.app file");r=e}return r}exports.generateIpa=generateIpa;