2026-10-12 16:41:42 +08:00
|
|
|
// 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')
|
2026-10-13 09:41:46 +08:00
|
|
|
const output = path.join(root, 'ruoyi-ui-vue3/dist')
|
2026-10-12 16:41:42 +08:00
|
|
|
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')}`)
|