first commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { app } from 'electron'
|
||||
import { join } from 'path'
|
||||
import { mkdirSync } from 'fs'
|
||||
|
||||
/**
|
||||
* Arborescence des données du launcher, rangée sous le userData d'Electron :
|
||||
* Windows : %APPDATA%/OFLauncher
|
||||
* Linux : ~/.config/OFLauncher
|
||||
*
|
||||
* On garde le runtime (MC/NeoForge/assets/libs/java) séparé de l'instance de
|
||||
* jeu (mods/config/saves) pour que la sync packwiz ne touche jamais au runtime.
|
||||
*/
|
||||
class LauncherPaths {
|
||||
/** Racine : userData d'Electron. */
|
||||
get root(): string {
|
||||
return app.getPath('userData')
|
||||
}
|
||||
|
||||
/** Dossier "Minecraft" géré par @xmcl : versions/, libraries/, assets/. */
|
||||
get gameRoot(): string {
|
||||
return this.ensure(join(this.root, 'minecraft'))
|
||||
}
|
||||
|
||||
/** Dossier d'instance du modpack : mods/, config/, saves/ (cible packwiz). */
|
||||
get instanceDir(): string {
|
||||
return this.ensure(join(this.root, 'instance'))
|
||||
}
|
||||
|
||||
/** Runtimes Java téléchargés (un sous-dossier par composant Mojang). */
|
||||
get javaDir(): string {
|
||||
return this.ensure(join(this.root, 'java'))
|
||||
}
|
||||
|
||||
/** Cache des tokens d'auth (prismarine-auth). */
|
||||
get authCache(): string {
|
||||
return this.ensure(join(this.root, 'auth-cache'))
|
||||
}
|
||||
|
||||
/** Fichier de réglages utilisateur. */
|
||||
get settingsFile(): string {
|
||||
return join(this.root, 'settings.json')
|
||||
}
|
||||
|
||||
/** jar packwiz-installer-bootstrap embarqué dans les resources. */
|
||||
get packwizBootstrapJar(): string {
|
||||
// En prod, electron-builder copie resources/ via extraResources.
|
||||
// En dev, on lit directement le dossier resources/ du repo.
|
||||
const base = app.isPackaged
|
||||
? join(process.resourcesPath, 'resources')
|
||||
: join(app.getAppPath(), 'resources')
|
||||
return join(base, 'packwiz-installer-bootstrap.jar')
|
||||
}
|
||||
|
||||
private ensure(dir: string): string {
|
||||
mkdirSync(dir, { recursive: true })
|
||||
return dir
|
||||
}
|
||||
}
|
||||
|
||||
export const paths = new LauncherPaths()
|
||||
Reference in New Issue
Block a user