Rewrite frontend as single self-contained HTML file — all CSS/JS inline, no external files to fail loading
This commit is contained in:
44
dist/utils/configUtils.js
vendored
Normal file
44
dist/utils/configUtils.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadConfigFromFile = loadConfigFromFile;
|
||||
exports.saveConfigToFile = saveConfigToFile;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
/**
|
||||
* Load configuration from a JSON file
|
||||
* @param filePath - Path to the configuration file
|
||||
* @returns Configuration object
|
||||
*/
|
||||
function loadConfigFromFile(filePath) {
|
||||
try {
|
||||
const configFile = fs_1.default.readFileSync(filePath, 'utf8');
|
||||
const config = JSON.parse(configFile);
|
||||
console.log(`Loaded configuration from ${filePath}`);
|
||||
return config;
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error loading config from ${filePath}:`, error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Save configuration to a JSON file
|
||||
* @param filePath - Path to save the configuration file
|
||||
* @param config - Configuration object to save
|
||||
*/
|
||||
function saveConfigToFile(filePath, config) {
|
||||
try {
|
||||
// Filter out non-configuration properties
|
||||
const configToSave = { ...config };
|
||||
const keysToExclude = ['_', '$0', 'video_file_path', 'estimate', 'config', 'saveConfig', 'help', 'version', 'h'];
|
||||
keysToExclude.forEach(key => delete configToSave[key]);
|
||||
fs_1.default.writeFileSync(filePath, JSON.stringify(configToSave, null, 2), 'utf8');
|
||||
console.log(`Configuration saved to ${filePath}`);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error saving config to ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=configUtils.js.map
|
||||
Reference in New Issue
Block a user