You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dev-sidecar/packages/gui/pkg/after-pack.js

40 lines
1.5 KiB

const path = require('path')
const AdmZip = require('adm-zip')
const pkg = require('../package.json')
3 years ago
const fs = require('fs')
function writeAppUpdateYmlForLinux () {
const publishUrl = process.env.VUE_APP_PUBLISH_URL
const publishProvider = process.env.VUE_APP_PUBLISH_PROVIDER
// provider: generic
// url: 'http://dev-sidecar.docmirror.cn/update/preview/'
// updaterCacheDirName: '@docmirrordev-sidecar-gui-updater'
const fileContent = `provider: ${publishProvider}
url: '${publishUrl}'
updaterCacheDirName: '@docmirrordev-sidecar-gui-updater'
`
console.log('write linux app-update.yml,updateUrl:', publishUrl)
const filePath = path.resolve('./dist_electron/linux-unpacked/resources/app-update.yml')
fs.writeFileSync(filePath, fileContent)
}
exports.default = async function (context) {
// console.log('context', context)
let targetPath
let systemType = ''
if (context.packager.platform.nodeName === 'darwin') {
targetPath = path.join(context.appOutDir, `${context.packager.appInfo.productName}.app/Contents/Resources`)
systemType = 'mac'
3 years ago
} else if (context.packager.platform.nodeName === 'linux') {
targetPath = path.join(context.appOutDir, './resources')
systemType = 'linux'
3 years ago
writeAppUpdateYmlForLinux()
} else {
targetPath = path.join(context.appOutDir, './resources')
systemType = 'win'
}
const zip = new AdmZip()
zip.addLocalFolder(targetPath)
const partUpdateFile = `update-${systemType}-${pkg.version}.zip`
zip.writeZip(path.join(context.outDir, partUpdateFile))
}