// Generates deployment artifacts from a completed web build; never changes source files. const fs = require('fs') const path = require('path') const crypto = require('crypto') const root = path.resolve(__dirname, '../..') const bundle = path.join(root, 'android-app/app/src/main/assets/web.zip') const output = path.join(root, 'ruoyi-ui-vue3/dist') if (!fs.existsSync(path.join(output, 'index.html'))) throw new Error('Build web pages first') const hash = crypto.createHash('sha256').update(fs.readFileSync(bundle)).digest('hex') const version = `web-${hash.slice(0, 24)}` const name = `${version}.zip` fs.copyFileSync(bundle, path.join(output, name)) fs.writeFileSync(path.join(output, 'mobile-update.json'), JSON.stringify({ version, sha256: hash, url: `/${name}`, minimumNativeVersion: 1 }, null, 2)) console.log(`Page update: ${path.join(output, 'mobile-update.json')}`)