add installer to build package

This commit is contained in:
olcxja 2026-09-25 20:38:23 +02:00
commit ada55faf13
88 changed files with 10828 additions and 25 deletions

View file

@ -3,10 +3,36 @@
const path = require('path')
const fs = require('fs')
const APP_ROOT = path.resolve(__dirname, '..')
// Packaged builds run from <portable root>/electron/resources/app.asar:
// the portable layout (<root>/files) is two levels above the resources dir
// and files bundled with the release are unpacked next to the asar.
function computeRoots() {
const m = __dirname.match(/^(.*)[/\\]app\.asar([/\\]|$)/)
if (m) {
const RESOURCES = path.resolve(m[1])
const APP_ROOT = path.resolve(RESOURCES, '..', '..')
return {
RESOURCES,
APP_ROOT,
// FILES = BUILD/files, so BUILD is the portable root itself.
BUILD: process.env.PLWL_BUILD_DIR || APP_ROOT,
// Bundled release files live inside the asar (Electron's patched fs
// can read them directly from the archive).
BUNDLED: fs.existsSync(path.join(RESOURCES, 'app.asar', 'files', 'translations'))
? path.join(RESOURCES, 'app.asar', 'files')
: path.join(APP_ROOT, 'files')
}
}
const APP_ROOT = path.resolve(__dirname, '..')
return {
RESOURCES: APP_ROOT,
APP_ROOT,
BUILD: process.env.PLWL_BUILD_DIR || path.join(APP_ROOT, 'build'),
BUNDLED: path.join(APP_ROOT, 'files')
}
}
const BUILD = process.env.PLWL_BUILD_DIR || path.join(APP_ROOT, 'build')
const BUNDLED = path.join(APP_ROOT, 'files')
const { RESOURCES, APP_ROOT, BUILD, BUNDLED } = computeRoots()
const FILES = path.join(BUILD, 'files')
const DATA = path.join(FILES, 'data')
@ -53,4 +79,4 @@ function writeJson(file, data) {
fs.renameSync(tmp, file)
}
module.exports = { APP_ROOT, BUILD, FILES, DATA, DIRS, ensureDirs, readJson, writeJson }
module.exports = { RESOURCES, APP_ROOT, BUILD, FILES, DATA, DIRS, ensureDirs, readJson, writeJson }