mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
fix: move config to AppData to prevent settings loss on update, add config.dev.json for dev environment
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,5 +7,7 @@
|
||||
/ressources/ffprobe.exe
|
||||
/ressources/deno.exe
|
||||
|
||||
config/config.dev.json
|
||||
|
||||
logs/*.json
|
||||
logs/*.log
|
||||
@@ -1,18 +1,10 @@
|
||||
const { ipcMain, dialog, shell } = require("electron");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { logger, logDir } = require("../server/logger");
|
||||
const { configFeatures } = require("../config");
|
||||
const { configFeatures, featuresPath } = require("../config");
|
||||
const config = require("../config");
|
||||
const { validateDownloadPath, getDefaultDownloadPath } = require("./pathValidator");
|
||||
|
||||
const configFolderPath = path.join(
|
||||
config.localMode
|
||||
|
||||
? path.join(__dirname, "..")
|
||||
: path.join(path.dirname(process.execPath), "resources"), "config", "config.json"
|
||||
);
|
||||
|
||||
const FEATURE_WHITELIST = new Set([
|
||||
"autoUpdate",
|
||||
"discordRPC",
|
||||
@@ -25,6 +17,8 @@ const FEATURE_WHITELIST = new Set([
|
||||
"customCodec",
|
||||
]);
|
||||
|
||||
const configFolderPath = featuresPath;
|
||||
|
||||
function registerIpcHandlers(getMainWindow) {
|
||||
|
||||
// Infos générales
|
||||
|
||||
38
config.js
38
config.js
@@ -5,23 +5,39 @@ const path = require("path");
|
||||
|
||||
const localMode = !app.isPackaged;
|
||||
|
||||
// Change path for JSON file
|
||||
const featuresPath = path.join(path.join(`${localMode ? __dirname : process.resourcesPath}`,"config/" , "config.json"));
|
||||
function resolveConfigPath() {
|
||||
if (localMode) {
|
||||
const devConfigPath = path.join(__dirname, "config", "config.dev.json");
|
||||
if (!fs.existsSync(devConfigPath)) {
|
||||
const defaultConfigPath = path.join(__dirname, "config", "config.default.json");
|
||||
fs.copyFileSync(defaultConfigPath, devConfigPath);
|
||||
}
|
||||
return devConfigPath;
|
||||
}
|
||||
|
||||
let features = {};
|
||||
const userConfigPath = path.join(app.getPath("userData"), "config.json");
|
||||
if (!fs.existsSync(userConfigPath)) {
|
||||
const defaultConfigPath = path.join(process.resourcesPath, "config", "config.default.json");
|
||||
fs.copyFileSync(defaultConfigPath, userConfigPath);
|
||||
}
|
||||
|
||||
return userConfigPath;
|
||||
}
|
||||
|
||||
const featuresPath = resolveConfigPath();
|
||||
|
||||
function loadFeatures() {
|
||||
const raw = fs.readFileSync(featuresPath, "utf-8");
|
||||
features = JSON.parse(raw);
|
||||
return features;
|
||||
const raw = fs.readFileSync(featuresPath, "utf-8");
|
||||
return JSON.parse(raw);
|
||||
}
|
||||
|
||||
const configFeatures = loadFeatures();
|
||||
|
||||
module.exports = {
|
||||
version: packageJson.version,
|
||||
applicationPort: "8787",
|
||||
localMode,
|
||||
DiscordRPCID: "1410934537051181146",
|
||||
configFeatures
|
||||
version: packageJson.version,
|
||||
applicationPort: "8787",
|
||||
localMode,
|
||||
DiscordRPCID: "1410934537051181146",
|
||||
configFeatures,
|
||||
featuresPath
|
||||
}
|
||||
@@ -37,7 +37,8 @@
|
||||
],
|
||||
"files": [
|
||||
"**/*",
|
||||
"node_modules/**/*"
|
||||
"node_modules/**/*",
|
||||
"!config/config.dev.json"
|
||||
],
|
||||
"directories": {
|
||||
"buildResources": "build"
|
||||
@@ -77,8 +78,8 @@
|
||||
"to": "binaries/deno.exe"
|
||||
},
|
||||
{
|
||||
"from": "config/config.json",
|
||||
"to": "config/config.json"
|
||||
"from": "config/config.default.json",
|
||||
"to": "config/config.default.json"
|
||||
}
|
||||
],
|
||||
"win": {
|
||||
|
||||
Reference in New Issue
Block a user