remove local files

This commit is contained in:
olcxja 2026-09-25 17:38:26 +02:00
commit e0173d410b
5 changed files with 0 additions and 317 deletions

View file

@ -1 +0,0 @@
6ff7a5d6-da3d-478b-b467-0c48d747aaa3

View file

@ -1,80 +0,0 @@
'use strict'
const path = require('path')
const fs = require('fs')
const prefixes = require('../src/prefixes')
const runner = require('../src/runner')
const wines = require('../src/wines')
async function main() {
const created = prefixes.createPrefix('e2e-test')
if (!created.ok && created.error !== 'alreadyExists') throw new Error('prefix create failed: ' + created.error)
const game = {
id: 'e2e-test',
name: 'E2E Test',
mode: 'leave',
path: '.',
exePath: 'C:\\windows\\system32\\cmd.exe',
workdir: path.resolve('.'),
wine: 'system',
prefix: 'e2e-test',
args: '/c echo PLGL-E2E-OK > C:\\plgl-e2e-out.txt',
dllOverrides: [{ dll: 'dinput8', setting: 'native' }],
env: { E2E_MARKER: '1' }
}
const { env } = runner.buildEnv({ game, wine: { id: 'system', type: 'system' }, systemWine: true })
if (!env.WINEPREFIX.includes('e2e-test')) throw new Error('WINEPREFIX mismatch: ' + env.WINEPREFIX)
if (env.WINEDLLOVERRIDES !== 'dinput8=native') throw new Error('dll overrides mismatch: ' + env.WINEDLLOVERRIDES)
if (env.E2E_MARKER !== '1') throw new Error('game env not applied')
console.log('PASS: system wine env', { WINEPREFIX: env.WINEPREFIX, WINEDLLOVERRIDES: env.WINEDLLOVERRIDES })
const protonDir = path.join(require('../src/paths').DIRS.WINES, 'e2e-fake-proton')
fs.mkdirSync(protonDir, { recursive: true })
fs.writeFileSync(path.join(protonDir, 'proton'), '#!/usr/bin/env python3\n')
await wines.refreshWines()
const proton = wines.getWines().find(w => w.id === 'e2e-fake-proton')
if (!proton) throw new Error('proton build not detected')
if (proton.type !== 'proton') throw new Error('wrong type: ' + proton.type)
const penv = runner.buildEnv({ game, wine: proton, systemWine: false }).env
if (penv.STEAM_COMPAT_DATA_PATH !== path.join(require('../src/paths').DIRS.DATA, 'compat', 'e2e-test')) {
throw new Error('compat path mismatch: ' + penv.STEAM_COMPAT_DATA_PATH)
}
if (penv.WINEPREFIX !== path.join(penv.STEAM_COMPAT_DATA_PATH, 'pfx')) throw new Error('proton WINEPREFIX mismatch')
if (fs.readlinkSync(penv.STEAM_COMPAT_DATA_PATH) !== prefixes.prefixPath('e2e-test')) {
throw new Error('compatdata is not symlinked to the prefix')
}
if (!fs.existsSync(penv.STEAM_COMPAT_CLIENT_INSTALL_PATH)) throw new Error('fake steam missing')
console.log('PASS: proton env', {
STEAM_COMPAT_DATA_PATH: penv.STEAM_COMPAT_DATA_PATH,
CLIENT_INSTALL_PATH: penv.STEAM_COMPAT_CLIENT_INSTALL_PATH
})
console.log('launching real wine...')
await runner.runGame({ game, wine: { id: 'system', type: 'system' }, systemWine: true })
for (let i = 0; i < 45; i++) {
await new Promise(r => setTimeout(r, 2000))
const outFile = path.join(env.WINEPREFIX, 'drive_c', 'plgl-e2e-out.txt')
if (fs.existsSync(outFile)) {
console.log('OUTPUT FILE CONTENT:', fs.readFileSync(outFile, 'utf8').trim())
console.log('E2E PASS: wine executed the exe and wrote the file')
prefixes.deletePrefix('e2e-test')
fs.rmSync(protonDir, { recursive: true, force: true })
await wines.refreshWines()
return
}
}
console.log('E2E SOFT-FAIL: prefix init not finished in time (first wine run can be slow)')
prefixes.deletePrefix('e2e-test')
fs.rmSync(protonDir, { recursive: true, force: true })
await wines.refreshWines()
}
main().catch(e => {
console.error(e)
process.exit(1)
})

View file

@ -1,77 +0,0 @@
'use strict'
const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
const html = fs.readFileSync(path.join(root, 'renderer', 'index.html'), 'utf8')
const css = fs.readFileSync(path.join(root, 'renderer', 'style.css'), 'utf8')
const appJs = fs.readFileSync(path.join(root, 'renderer', 'app.js'), 'utf8')
const en = JSON.parse(fs.readFileSync(path.join(root, 'files', 'translations', 'en-us.json'), 'utf8'))
const pl = JSON.parse(fs.readFileSync(path.join(root, 'files', 'translations', 'pl.json'), 'utf8'))
const fonts = {
regular: fs.readFileSync(path.join(root, 'renderer', 'Nunito-Regular.ttf')).toString('base64'),
black: fs.readFileSync(path.join(root, 'renderer', 'Nunito-Black.ttf')).toString('base64')
}
const mock = `
window.plgl = {
FILES_DIR: '/home/user/PLGL/files',
i18nList: async () => [
{ code: 'en-us', nameEn: ${JSON.stringify(en.data.nameEn)}, nameSelf: ${JSON.stringify(en.data.nameSelf)} },
{ code: 'pl', nameEn: ${JSON.stringify(pl.data.nameEn)}, nameSelf: ${JSON.stringify(pl.data.nameSelf)} }
],
i18nGet: async code => ({ 'en-us': ${JSON.stringify(en)}, 'pl': ${JSON.stringify(pl)} }[code] || ${JSON.stringify(en)}),
settingsGet: async () => ({ language: 'en-us', defaultWine: 'proton-ge-proton9-20' }),
settingsSet: async p => ({ language: 'en-us', defaultWine: 'proton-ge-proton9-20', ...p }),
winesList: async () => [
{ id: 'system', type: 'system', label: 'System Wine', version: '11.0' },
{ id: 'proton-ge-proton9-20', type: 'proton', label: 'Proton GE 9.20', path: '/home/user/PLGL/files/wines/proton-ge-proton9-20' },
{ id: 'wine-10.2', type: 'wine', label: 'Wine 10.2', path: '/home/user/PLGL/files/wines/wine-10.2', version: '10.2' },
{ id: 'wine-old-5.0', type: 'wine', label: 'Wine 5.0', path: '/home/user/PLGL/files/wines/wine-old', version: '5.0', disabled: true }
],
winesRefresh: async () => [],
winesSetDisabled: async () => {},
winesSetDefault: async id => ({ ok: true, defaultWine: id }),
winesDelete: async id => id === 'system' ? ({ ok: false, error: 'isSystem' }) : ({ ok: true }),
winesImport: async src => ({ ok: true, path: src }),
prefixesList: async () => ({ default: 'Main', prefixes: [ { name: 'Main', created: 1, locked: true }, { name: 'gaming', created: 2 } ] }),
prefixesCreate: async name => ({ ok: true, name }),
prefixesDelete: async n => n === 'Main' ? ({ ok: false, error: 'isMain' }) : ({ ok: true }),
prefixesSetDefault: async () => ({ ok: true }),
gamesList: async () => [
{ id: 'g1', name: 'Cyberpunk 2077', mode: 'copy', wine: 'proton-ge-proton9-20', prefix: '', args: '--launcher-skip', env: { 'DXVK_HUD': '0' }, dllOverrides: [{ dll: 'dinput8', setting: 'native' }], workdir: '/home/user/PLGL/files/apps/Cyberpunk 2077/bin/x64', exePath: '/home/user/PLGL/files/apps/Cyberpunk 2077/bin/x64/Cyberpunk2077.exe', created: 1, lastPlayed: Date.now() - 86400000 },
{ id: 'g2', name: 'Heroes of Might and Magic III', mode: 'leave', wine: 'system', prefix: 'gaming', args: '', env: {}, dllOverrides: [], workdir: '/mnt/games/HoMM3', exePath: '/mnt/games/HoMM3/h3game.exe', created: 2, lastPlayed: 0 }
],
gamesGet: async () => null,
gamesUpdate: async (id, patch) => patch,
gamesRemove: async () => {},
gamesPickFolder: async () => '',
gamesImport: async (src, mode) => ({ id: 'g9', name: 'Imported Game', mode, wine: 'system', prefix: '', args: '', env: {}, dllOverrides: [], workdir: src, exePath: src + '/game.exe', lastPlayed: 0 }),
gamesRun: async () => ({ ok: true }),
gamesRunTool: async () => ({ ok: true }),
gamesGetLogs: async () => [],
gamesIsRunning: async () => false,
gamesKill: async () => ({ ok: true }),
gamesListRunning: async () => [],
onGamesChanged: () => {},
dialogPickFile: async () => '',
shellOpenPath: async () => {},
shellShowItemInFolder: async () => {},
onImportProgress: () => {}
}
`
const fontCss = `
@font-face { font-family: 'Nunito'; src: url(data:font/ttf;base64,${fonts.regular}) format('truetype'); }
@font-face { font-family: 'Nunito Black'; src: url(data:font/ttf;base64,${fonts.black}) format('truetype'); }
`
let out = html
.replace(/<meta http-equiv="Content-Security-Policy"[^>]*>/, '')
.replace('<link rel="stylesheet" href="style.css">', `<style>${fontCss}${css}</style>`)
.replace('<script src="app.js"></script>', `<script>${mock}</script>\n<script>(() => {\n${appJs}\n})()</script>`)
fs.writeFileSync(path.join(root, 'renderer', 'dev-preview.html'), out)
console.log('renderer/dev-preview.html generated')

View file

@ -1,67 +0,0 @@
'use strict'
const path = require('path')
const fs = require('fs')
const runner = require('../src/runner')
const wines = require('../src/wines')
async function main() {
await wines.refreshWines()
const proton = wines.getWines().find(w => w.type === 'proton')
if (!proton) {
console.log('NO PROTON IMPORTED')
return
}
console.log('using:', proton.id, proton.path)
const game = {
id: 'proton-e2e',
name: 'Proton E2E',
mode: 'leave',
path: '.',
exePath: 'C:\\windows\\system32\\cmd.exe',
workdir: path.resolve('.'),
wine: proton.id,
prefix: '',
args: '/c echo PROTON-RUNNER-OK > C:\\proton-runner.txt',
dllOverrides: [],
env: {}
}
const env = runner.buildEnv({ game, wine: proton }).env
console.log('STEAM_COMPAT_DATA_PATH:', env.STEAM_COMPAT_DATA_PATH)
console.log('symlinked to:', fs.readlinkSync(env.STEAM_COMPAT_DATA_PATH))
console.log('WINEPREFIX:', env.WINEPREFIX)
const exitPromise = new Promise(resolve => {
runner.runGame({
game,
wine: proton,
onExit: (code, signal) => resolve({ code, signal })
})
})
for (let i = 0; i < 60; i++) {
await new Promise(r => setTimeout(r, 2000))
const outFile = path.join(env.WINEPREFIX, 'drive_c', 'proton-runner.txt')
if (fs.existsSync(outFile)) {
console.log('OUTPUT:', fs.readFileSync(outFile, 'utf8').trim())
console.log('PROTON E2E PASS')
return
}
}
console.log('TIMEOUT waiting for output file')
const logs = fs.readdirSync(path.join(require('../src/paths').DIRS.DATA, 'logs')).filter(f => f.startsWith('proton-e2e'))
if (logs.length) {
const log = fs.readFileSync(path.join(require('../src/paths').DIRS.DATA, 'logs', logs[logs.length - 1]), 'utf8')
console.log('LOG TAIL:', log.slice(-2000))
}
const { code } = await Promise.race([exitPromise, new Promise(r => setTimeout(() => r({ code: 'still-running' }), 30000))])
console.log('exit:', code)
}
main().catch(e => {
console.error(e)
process.exit(1)
})

View file

@ -1,92 +0,0 @@
'use strict'
const assert = require('assert')
const path = require('path')
const fs = require('fs')
const runner = require('../src/runner')
const i18n = require('../src/i18n')
function testParseArgs() {
assert.deepStrictEqual(runner.parseArgs('-dx11 -windowed'), ['-dx11', '-windowed'])
assert.deepStrictEqual(runner.parseArgs('--foo "bar baz" --n=1'), ['--foo', 'bar baz', '--n=1'])
assert.deepStrictEqual(runner.parseArgs("a 'b c' d"), ['a', 'b c', 'd'])
assert.deepStrictEqual(runner.parseArgs(''), [])
}
function testLinkPrefix() {
const tmp = fs.mkdtempSync('/tmp/plgl-test-')
const compat = path.join(tmp, 'compatdata')
const prefix = path.join(tmp, 'pfx-target')
fs.mkdirSync(prefix)
fs.symlinkSync(prefix, compat, 'dir')
assert.strictEqual(fs.readlinkSync(compat), prefix)
fs.rmSync(tmp, { recursive: true, force: true })
}
async function testI18n() {
require('../src/paths').ensureDirs()
const langs = await i18n.init()
assert.ok(langs.length >= 2)
const codes = i18n.listLangs().map(l => l.code)
assert.ok(codes.includes('en-us'))
assert.ok(codes.includes('pl'))
const en = i18n.getLang('en-us')
assert.strictEqual(en.data.nameEn, 'English')
assert.strictEqual(i18n.translate('pl', 'toast.saved'), 'Zapisano')
assert.strictEqual(i18n.translate('en-us', 'library.lastPlayed', 'x', 'y'), 'Last played x')
assert.strictEqual(i18n.translate('en-us', 'nonexistent.key'), 'nonexistent.key')
}
function testTranslationsAreValidJson() {
const dir = require('../src/paths').DIRS.BUNDLED_TRANSLATIONS
for (const f of fs.readdirSync(dir)) {
if (!f.endsWith('.json')) continue
const data = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'))
assert.ok(data.data && data.data.nameEn && data.data.nameSelf, f + ' missing data')
assert.ok(data.texts && typeof data.texts === 'object' && Object.keys(data.texts).length > 10, f + ' missing texts')
}
}
function testPaths() {
const { DIRS } = require('../src/paths')
assert.ok(DIRS.WINES.endsWith('files/wines'))
assert.ok(DIRS.PREFIXES.endsWith('wineprefixes'))
assert.ok(DIRS.FILES.includes('/build/'))
}
function testMainPrefix() {
const prefixes = require('../src/prefixes')
const defs = prefixes.listPrefixes()
assert.ok(defs.prefixes.some(p => p.name === 'Main'), 'Main prefix must exist')
assert.strictEqual(defs.default, 'Main')
assert.ok(defs.prefixes.find(p => p.name === 'Main').locked, 'Main must be locked')
const del = prefixes.deletePrefix('Main')
assert.strictEqual(del.ok, false)
assert.strictEqual(del.error, 'isMain')
const dup = prefixes.createPrefix('Main')
assert.strictEqual(dup.ok, false)
assert.ok(prefixes.prefixExists('Main'))
const created = prefixes.createPrefix('test-prefix-x')
assert.ok(created.ok)
const setDef = prefixes.setDefaultPrefix('test-prefix-x')
assert.ok(setDef.ok)
assert.strictEqual(prefixes.listPrefixes().default, 'test-prefix-x')
prefixes.deletePrefix('test-prefix-x')
assert.strictEqual(prefixes.listPrefixes().default, 'Main')
}
async function run() {
testParseArgs()
testLinkPrefix()
testI18n()
testTranslationsAreValidJson()
testPaths()
testMainPrefix()
console.log('All smoke tests passed')
}
run().catch(e => {
console.error(e)
process.exit(1)
})