import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import {fileURLToPath} from 'node:url'; const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..'),snapshot=path.join(root,'updates/2026-09-05'),dest=path.join(root,'release/app'); const copy=(src,to)=>{fs.mkdirSync(path.dirname(to),{recursive:true});fs.cpSync(src,to,{recursive:true});}; copy(snapshot+'/deployed/main.cjs',dest+'/main.cjs'); let main=fs.readFileSync(dest+'/main.cjs','utf8');const marker='"use strict";var ibn=Object.create;'; if(main.split(marker).length!==2)throw Error('Unexpected bundle');main=main.slice(main.indexOf(marker)); const call=';triliumApplyKoreanNotes();triliumApplyKoreanPhase4();triliumApplyKoreanPdf();triliumApplyKoreanApiLinks()'; if(main.split(call).length!==2)throw Error('Unexpected migration calls');main=main.replace(call,''); if(/triliumApplyKorean/.test(main))throw Error('One-off migration remained');fs.writeFileSync(dest+'/main.cjs',main); copy(snapshot+'/deployed/translation.json',dest+'/public/translations/ko/translation.json');copy(snapshot+'/deployed/server.json',dest+'/assets/translations/ko/server.json'); for(const n of ['layout_commons.js','mobile_layout.js','ko.js','ckeditor-ko.js','ckeditor5.js','MindElixir.js','emoji-ko.json'])copy(snapshot+'/deployed/'+n,dest+'/public/src/'+n); for(const phase of [3,8,9])copy(snapshot+'/phase'+phase+'/doc_notes/en',dest+'/assets/doc_notes/en'); copy(root+'/release/demo-ko.zip',dest+'/assets/db/demo.zip'); const metadata={release:'2.0.0',appVersion:'0.95.0',baseImage:'triliumnext/notes@sha256:611a430016585d35b170eb9a0fa300ce76318f04a8ec0067549c4c52561b0c36',assetVersion:'v0.95.0-ko-20260913-r8',scope:'한국어 UI와 도움말 및 신규 설치용 기본 예제',files:{}}; for(const name of fs.readdirSync(dest,{recursive:true}).filter(n=>fs.statSync(path.join(dest,n)).isFile()).sort()){const bytes=fs.readFileSync(path.join(dest,name));metadata.files[name.replaceAll('\\','/')]={bytes:bytes.length,sha256:crypto.createHash('sha256').update(bytes).digest('hex')};} fs.writeFileSync(root+'/release/manifest.json',JSON.stringify(metadata,null,2)+'\n');console.log({files:Object.keys(metadata.files).length,release:metadata.release});